StringBuffer 和 StringBuilder
介绍
源码解析
AbstractStringBuilder
变量及构造方法
/**
* 用来存储字符的数组
* The value is used for character storage.
*/
char[] value;
/**
* 字符个数
* The count is the number of characters used.
*/
int count;
/**
* This no-arg constructor is necessary for serialization of subclasses.
*/
AbstractStringBuilder() {
}
/**
* 在构造方法中指定字符数组的长度
* Creates an AbstractStringBuilder of the specified capacity.
*/
AbstractStringBuilder(int capacity) {
value = new char[capacity];
}扩容
append() 方法
思考
StringBuilder 与 StringBuffer 方法对比
Last updated