String Performance
Perhaps string concatenation is the most frequently used string operation in any language. In Java you can concat two string in this manner:
String concatdStr = "String1"+"String2"+" and String3";
But this is not a good idea. Behind the curtain , Java does string concatenation using StringBuffer class. So the above concat becomes :
String sBuf = new StringBuffer(32);
sBuf.append("String1").append("String2").append(" and String3");
String concatdStr = "String1"+"String2"+" and String3";
But this is not a good idea. Behind the curtain , Java does string concatenation using StringBuffer class. So the above concat becomes :
String sBuf = new StringBuffer(32);
sBuf.append("String1").append("String2").append(" and String3");
Comments