/**
* The value is used for character storage.
*/
char[] value;
/**
* The count is the number of characters used.
*/
int count;
这是此类的两个成员变量,value是存储字符用的,value.length表示字符容量。
count表示已经使用的长度。
对应的方法:
/**
* Returns the length (character count).
*
* @return the length of the sequence of characters currently
* represented by this object
*/
public int length() {
return count;
}
/**
* Returns the current capacity. The capacity is the amount of storage
* available for newly inserted characters, beyond which an allocation
* will occur.
*
* @return the current capacity
*/
public int capacity() {
return value.length;
}
本文介绍了用于字符存储的数组变量value及其长度属性count。value数组用于存放字符,其长度value.length表示字符容量;count变量记录了已使用字符的数量,通过length()方法返回当前字符数量,capacity()方法返回字符的最大容量。
1766

被折叠的 条评论
为什么被折叠?



