1.两者内部都是通过维护char[] 来装载数据 。
2.线程同步问题:对于applend()方法,StringBuilder 非线程安全,StringBuffer线程安全。
public StringBuilder append(CharSequence s, int start, int end) {
super.append(s, start, end);
return this;
}
public AbstractStringBuilder append(String str) {
if (str == null) str = "null";
int len = str.length();
ensureCapacityInternal(count + len);
str.getChars(0, len, value, count);
count += len;
return this;
}