An Efficient Method of String Concatenation


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 " );

From DevX

你可能感兴趣的:(String)