我已经审查了Java.lang.String
实现。构造函数让我感到困惑。
为什么result.value,result.count,result.offset
可以直接使用。
因为三人的财产都是私人的!!!
/** The value is used for character storage. */
private final char value[];
/** The offset is the first index of the storage that is used. */
private final int offset;
/** The count is the number of characters in the String. */
private final int count;
public String(StringBuilder builder) {
String result = builder.toString();
this.value = result.value;
this.count = result.count;
this.offset = result.offset;
}