To improve performance, instead of using string concatenation, use StringBuffer.append(). String objects are immutable; they never change after creation. For example, consider the following code:
tring str = "testing"; str = str + "abc";
The compiler translates this code as:
String str = "testing";
StringBuffer tmp = new StringBuffer(str);
tmp.append("abc");
str = tmp.toString();
Therefore, copying is inherently expensive and overusing it can reduce performance significantly.