An Efficient Method of String Concatenation
Posted on 2005-04-28 13:31 Rickel 阅读(392) 评论(0) 编辑 收藏 举报A good way to concatenate strings in a loop or when performing multiple concatenations, is to use the StringBuilder class:
1String s = "a"
2s+="b"; //this is slow
3
4StringBuilder sb = new StringBuilder();
5sb.Append("a");
6sb.Append("b");
2s+="b"; //this is slow
3
4StringBuilder sb = new StringBuilder();
5sb.Append("a");
6sb.Append("b");
From DevX