StringBuilder 单线程安全,效率高 ,StringBuffer 多线程安全。
StringBuilder()
构造一个其中不带字符的字符串生成器,初始容量为 16 个字符。
StringBuilder(String str)
构造一个字符串生成器,并初始化为指定的字符串内容。
StringBuilder | append(Object obj) 基础类型,String,StringBuffer, |
StringBuilder | insert(int offset, Object obj) 基础类型,String |
StringBuilder | delete(int start, int end) Removes the characters in a substring of this sequence. |
StringBuilder | deleteCharAt(int index) Removes the char at the specified position in this sequence. |
int | indexOf(String str) Returns the index within this string of the first occurrence of the specified substring. |
int | indexOf(String str, int fromIndex) Returns the index within this string of the first occurrence of the specified substring, starting at the specified index. |
int | lastIndexOf(String str) Returns the index within this string of the rightmost occurrence of the specified substring. |
int | lastIndexOf(String str, int fromIndex) Returns the index within this string of the last occurrence of the specified substring. |
int | length() Returns the length (character count). |
int | offsetByCodePoints(int index, int codePointOffset) Returns the index within this sequence that is offset from the given index by codePointOffset code points. |
StringBuilder | replace(int start, int end, String str) Replaces the characters in a substring of this sequence with characters in the specified String . |
StringBuilder | reverse() Causes this character sequence to be replaced by the reverse of the sequence. |
void | setCharAt(int index, char ch) The character at the specified index is set to ch . |
void | setLength(int newLength) Sets the length of the character sequence. |
CharSequence | subSequence(int start, int end) Returns a new character sequence that is a subsequence of this sequence. |
String | substring(int start) Returns a new String that contains a subsequence of characters currently contained in this character sequence. |
String | substring(int start, int end) Returns a new String that contains a subsequence of characters currently contained in this sequence. |
String | toString() Returns a string representing the data in this sequence. |
void | trimToSize() Attempts to reduce storage used for the character sequence. |