技不如人

Welcome to Rickel's blog.
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

An Efficient Method of String Concatenation

Posted on 2005-04-28 13:31  Rickel  阅读(391)  评论(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");

From DevX