Hi, It is well known that if one has to perform a lot of concatenation operations on a string, then using string buffer gives a better performance than just strings. However if the strings I was using were static members of a class, would this improve the performance as compared to using regular strings ? If so, would string buffers still be the better choice ?
I agree with Tony, Lionel, and David - if you're concatenating compile-time constants like "x" and "y" (or, as often happens, some other string which is too long to fit nicely on a single line of Java code), then using the + is both fastest and nicest (to look at). If one of the things you're concatenating is a variable though (that is, a variable that's not a compile-time constant), and if you're doing the concatenation more than once, especially in a loop - that's when StringBuffer's append() is preferred. [ February 03, 2005: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding, Twister
subject: Using static strings gives the same/better performance as string buffers