public class String2
{
public static void main ( String [] args )
{
String str1 = new String("Any old");
String str2 = " String";
String aString = str1 + str2; // aString is "Any old String"
// Show string str1
System.out.println("str1: " + str1);
// Show string str2
System.out.println("str2: " + str2);
// Show the result of concatenating a and b
System.out.println("str1 + str2: " + aString);
// Show the number of characters in the string
System.out.println("length: " + aString.length());
}
}
Back to Lesson 2 Examples
Back to Java Main Page