I have been using String to do the following.
String x = "a";
String y = "b";
String z = y+""+x;
x = y;
y = z;
So the final values of x and y are b and ba. I tried to use StringBuffer.
StringBuffer x = new StringBuffer("a");
StringBuffer y = new StringBuffer("b");
StringBuffer z = new StringBuffer();
z = y+""+x; //???
API provides append function but it doesn’t do what concatenation does. Is there a equivalent for concatenation in StringBuffer class?
Dont’ use StringBuffer unless you have to. Java 5.0 and later uses StringBuilder by default