1、 线程不安全
public StringBuilder append(CharSequence s, int start, int end) {
super.append(s, start, end);
return this;
}
2、每个方法都是返回自己的对象,所以可以串行化的调用。
public StringBuilder append(CharSequence s, int start, int end) {
super.append(s, start, end);
return this;
}
public StringBuilder append(char[] str) {
super.append(str);
return this;
}
public StringBuilder append(char[] str, int offset, int len) {
super.append(str, offset, len);
return this;
}
public StringBuilder append(boolean b) {
super.append(b);
return this;
}
@Override
public StringBuilder append(char c) {
super.append(c);
return this;
}
@Override
public StringBuilder append(int i) {
super.append(i);
return this;
}
@Override
public StringBuilder append(long lng) {
super.append(lng);
return this;
}
@Override
public StringBuilder append(float f) {
super.append(f);
return this;
}
@Override
public StringBuilder append(double d) {
super.append(d);
return this;
}
public StringBuilder appendCodePoint(int codePoint) {
super.appendCodePoint(codePoint);
return this;
}
public StringBuilder delete(int start, int end) {
super.delete(start, end);
return this;
}
3、可以设置容量
public StringBuilder() {
super(16);
}
public StringBuilder(int capacity) {
super(capacity);
}
使用中一定要注意它的特性。