String class: + vs concat
posted 13 years ago
Curious. I'd never loooked at concat before. About the only thing that looks different is when the string you are adding has zero length it just gives you back the original instead of creating a new String. The + operator can be a bit expensive ... if you are doing hundreds or thousands of string building operations look into StringBuffer.append(). It is common to see a method build up a StringBuffer and then return or use theBuffer.toString() at the end.