Thi*_*ilo 10

是的,加上一些元数据,比如开始和结束索引(因为可以跨字符串共享char数组,例如,当您创建子字符串时).

查看源代码java.lang.String,您会看到以下实例字段:

/** 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;

/** Cache the hash code for the string */
private int hash; // Default to 0
Run Code Online (Sandbox Code Playgroud)