因此,当我偶然发现一个令人困惑的构造函数时,我正在阅读 String 类。代码是这样的
public final class String
implements java.io.Serializable, Comparable<String>, CharSequence {
/** The value is used for character storage. */
private final char value[];
/** Initializes a newly created {@code String} object so that it represents
* an empty character sequence. Note that use of this constructor is
* unnecessary since Strings are immutable.
*/
public String() {
this.value = "".value;
}
// the rest of the class code
}
我不明白什么是
"".value;
做。这是什么""
?是新的String object
吗?如果是,用什么构造函数?