StringBuilder类下的:
public StringBuilder append(String str) { // str = "123"
super.append(str);
return this;
}
AbstractStringBuilder类下的:
// 保存字符的数组对象
char[] value;
//字符的数量
int count;
public AbstractStringBuilder append(String str) {
if (str == null)
return appendNull();
int len = str.length();
ensureCapacityInternal(count + len); // 扩容
str.getChars(0, len, value, count); // AbstractStringBuilder类下的属性 char[] value; 功能是将String的值赋值给value字符数组
count += len;
return this;
}
// String类下的:
public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
// 边界检查 ... 省略
// 将value的值 1,2,3 拷贝到数组(dst)中
System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
}