A good way to concatenate strings in a loop or when performing multiple concatenations, is to use the StringBuilder class:
1
String s = "a"
2
s+="b"; //this is slow
3
4
StringBuilder sb = new StringBuilder();
5
sb.Append("a");
6
sb.Append("b");
String s = "a"2
s+="b"; //this is slow3

4
StringBuilder sb = new StringBuilder();5
sb.Append("a");6
sb.Append("b");From DevX
浙公网安备 33010602011771号