String greeting = "Hello world!";
String string1 = "Hey";
String string2 = " now";
string1.concat(string2);
System.out.println(string1); // Maybe not what is expected
string1 = string1.concat(string2);
System.out.println(string1); // Interesting!
StringBuffer b = new StringBuffer("Hello");
System.out.println(b);
b.append(", world!");
System.out.println(b);
String fs;
fs = String.format("The value of the float variable is " +
"%f, while the value of the integer " +
"variable is %d, and the string " +
"is %s", floatVar, intVar, stringVar);
System.out.println(fs);
abstract default goto package this
assert do if private throw
boolean double implements protected throws
break else import public transient
byte enum instanceof return true
case extends int short try
catch false interface static void
char final long strictfp volatile
class finally native super while
const float new switch
continue for null synchronized
System.out.println("Hello"); // println is a static method
System.out.println("Length of the word car is: " + "car".length());
// length method of String class not static (is an instance method)
* Some materials from www.tutorialspoint.com.