Wednesday, December 21, 2011

String vs StringBuffer

The following article explains with simple examples when it is more efficient to use the + operator vs StringBuffer.append to concatenate Strings.  It explains that the choice depends on the nature of the strings.  Use + if they are all resolvable at compile time.  Use StringBuffer if they are only resolvable at run time.

http://www.precisejava.com/javaperf/j2se/StringAndStringBuffer.htm