Java String Concatenation and Performance ~ Joey’s Scribble’s. “The quick and dirty way to concatenate strings in Java is to use the concatenation operator (+). This will yield a reasonable performance if you need to combine two or three strings (fixed-size). But if you want to concatenate n strings in a loop, the performance degrades in multiples of n.” An article that compares the speed of 4 different ways to concatenating Strings in Java. Using StringBuilder is clearly the fastest but it is interesting to see the range of differences. The comments to the article also mention when StringBuffer should be preferred.
via Dz0ne