62,633
社区成员
发帖
与我相关
我的任务
分享
/**
* The value is used for character storage.
*/
char value[];
/**
* The count is the number of characters used.
*/
int count;
public synchronized int length() {
return count;
}
public synchronized int capacity() {
return value.length;
}
# /**
# * This implements the expansion semantics of ensureCapacity with no
# * size check or synchronization.
# */
# void expandCapacity(int minimumCapacity) {
# int newCapacity = (value.length + 1) * 2;
# if (newCapacity < 0) {
# newCapacity = Integer.MAX_VALUE;
# } else if (minimumCapacity > newCapacity) {
# newCapacity = minimumCapacity;
# }
# char newValue[] = new char[newCapacity];
# System.arraycopy(value, 0, newValue, 0, count);
# value = newValue;
# }