java.lang.*中StringBuffer 源代码详解
- 核心方法
- StringBuffer()构造方法
- synchronized int length()
- synchronized int capacity()
- synchronized char charAt()
- synchronized void setCharAt()
- synchronized StringBuffer insert()
- int indexOf()
- int lastIndexOf()
- synchronized String toString()
- synchronized void writeObject()
- void readObject()
核心方法
StringBuffer()构造方法[OK]
synchronized int length() 实际存在的字符长度[OK]
synchronized int capacity() 容量的长度[OK]
synchronized char charAt() 返回指定索引位置的字符[OK]
synchronized void setCharAt() 设置指定索引位置的字符[OK]
synchronized StringBuffer insert() 往指定索引位置插入对象
int indexOf()
int lastIndexOf()
synchronized String toString()
synchronized void writeObject()
void readObject()
StringBuffer()构造方法
public StringBuffer() {
super(16);
}
public StringBuffer(int capacity) {
super(capacity);
}
public StringBuffer(String str) {
super(str.length() + 16);
append(str);
}
public StringBuffer(CharSequence seq) {
this(seq.length() + 16);
append(seq);
}
synchronized int length()
public synchronized int length() {
return count;
}
synchronized int capacity()
public synchronized int capacity() {
return value.length;
}
synchronized char charAt()
public synchronized char charAt(int index) {
if ((index < 0) || (index >= count))
throw new StringIndexOutOfBoundsException(index);
return value[index];
}
synchronized void setCharAt()
public synchronized void setCharAt(int index, char ch) {
if ((index < 0) || (index >= count))
throw new StringIndexOutOfBoundsException(index);
toStringCache = null;
value[index] = ch;
}
synchronized StringBuffer insert()
public synchronized StringBuffer insert(int index, char[] str, int offset,
int len)
{
toStringCache = null;
super.insert(index, str, offset, len);
return this;
}
public synchronized StringBuffer insert(int offset, Object obj) {
toStringCache = null;
super.insert(offset, String.valueOf(obj));
return this;
}
public synchronized StringBuffer insert(int offset, String str) {
toStringCache = null;
super.insert(offset, str);
return this;
}
public synchronized StringBuffer insert(int offset, char[] str) {
toStringCache = null;
super.insert(offset, str);
return this;
}
public StringBuffer insert(int dstOffset, CharSequence s) {
super.insert(dstOffset, s);
return this;
}
public synchronized StringBuffer insert(int dstOffset, CharSequence s,
int start, int end)
{
toStringCache = null;
super.insert(dstOffset, s, start, end);
return this;
}
public StringBuffer insert(int offset, boolean b) {
super.insert(offset, b);
return this;
}
public synchronized StringBuffer insert(int offset, char c) {
toStringCache = null;
super.insert(offset, c);
return this;
}
public StringBuffer insert(int offset, int i) {
super.insert(offset, i);
return this;
}
public StringBuffer insert(int offset, long l) {
super.insert(offset, l);
return this;
}
public StringBuffer insert(int offset, float f) {
super.insert(offset, f);
return this;
}
public StringBuffer insert(int offset, double d) {
super.insert(offset, d);
return this;
}
int indexOf()
int lastIndexOf()
synchronized String toString()
synchronized void writeObject()
void readObject()