一、什么用?
二、怎么用?
public class Hi {
public static void main(String[] args){
String s = "";
for(int i = 0;i<1000;i++){
s = s+","+i;
}
System.out.println(s);
StringBuilder sb = new StringBuilder(1024);
for (int i = 0; i < 1000; i++) {
sb.append(',').append(i);
}
System.out.println(s);
}
}
— 图片来自Java StringBuffer 和 StringBuilder 类 | 菜鸟教程