String 一经创建,不可更改,每次更改都是创建新对象,销毁旧对象
StringBuilder 创建后可修改,多线程不安全
StringBuffer 创建后可修改,多线程安全
StringBuffer函数列表
1 StringBuffer() 2 StringBuffer(int capacity) 3 StringBuffer(String string) 4 StringBuffer(CharSequence cs) 5 6 StringBuffer append(boolean b) 7 StringBuffer append(int i) 8 StringBuffer append(long l) 9 StringBuffer append(float f) 10 StringBuffer append(double d) 11 synchronized StringBuffer append(char ch) 12 synchronized StringBuffer append(char[] chars) 13 synchronized StringBuffer append(char[] chars, int start, int length) 14 synchronized StringBuffer append(Object obj) 15 synchronized StringBuffer append(String string) 16 synchronized StringBuffer append(StringBuffer sb) 17 synchronized StringBuffer append(CharSequence s) 18 synchronized StringBuffer append(CharSequence s, int start, int end) 19 StringBuffer appendCodePoint(int codePoint) 20 int capacity() 21 synchronized char charAt(int index) 22 synchronized int codePointAt(int index) 23 synchronized int codePointBefore(int index) 24 synchronized int codePointCount(int beginIndex, int endIndex) 25 synchronized StringBuffer delete(int start, int end) 26 synchronized StringBuffer deleteCharAt(int location) 27 synchronized void ensureCapacity(int min) 28 synchronized void getChars(int start, int end, char[] buffer, int idx) 29 synchronized int indexOf(String subString, int start) 30 int indexOf(String string) 31 StringBuffer insert(int index, boolean b) 32 StringBuffer insert(int index, int i) 33 StringBuffer insert(int index, long l) 34 StringBuffer insert(int index, float f) 35 StringBuffer insert(int index, double d) 36 synchronized StringBuffer insert(int index, char ch) 37 synchronized StringBuffer insert(int index, char[] chars) 38 synchronized StringBuffer insert(int index, char[] chars, int start, int length) 39 synchronized StringBuffer insert(int index, String string) 40 StringBuffer insert(int index, Object obj) 41 synchronized StringBuffer insert(int index, CharSequence s) 42 synchronized StringBuffer insert(int index, CharSequence s, int start, int end) 43 int lastIndexOf(String string) 44 synchronized int lastIndexOf(String subString, int start) 45 int length() 46 synchronized int offsetByCodePoints(int index, int codePointOffset) 47 synchronized StringBuffer replace(int start, int end, String string) 48 synchronized StringBuffer reverse() 49 synchronized void setCharAt(int index, char ch) 50 synchronized void setLength(int length) 51 synchronized CharSequence subSequence(int start, int end) 52 synchronized String substring(int start) 53 synchronized String substring(int start, int end) 54 synchronized String toString() 55 synchronized void trimToSize()