I\'m trying to understand what the best practice is and why for concatenating string literals and variables for different cases. For instance, if I have code like this
Optimization is done automatically by the compiler.
The Java2 compiler will automatically convert the following:
String s = s1 + s2;
to
String s = (new StringBuffer()).append(s1).append(s2).toString();
Taken straight from the Java Best Practices on Oracles website.