Originally posted by Adam Schaible:
This would fall into the lines of premature optimization - especially considering the IBM 1.5 compiler will do it automatically anytime you have string + string.
Sun introduced the StringBuilder class in J2SE 5.0, which is almost the same as StringBuffer, except it's not thread-safe. Thread safety is usually not necessary with StringBuffer, since it is seldom shared between threads. When Strings are added using the + operator, the compiler in J2SE 5.0 and Java SE 6 will automatically use StringBuilder. If StringBuffer is hard-coded, this optimization will not occur.
Originally posted by Joanne Neal:
[ November 09, 2007: Message edited by: Joanne Neal ]
I think that's unlikely. The concatenation may degrade performance by creating a lot of temporary extra objects, but those objects should all available for garbage collection. If you're getting OutOfMemoryError, it's because something cannot be collected. You probably need to look elsewhere.