The following API annotations contain important methods in the StringBuilder class
append(boolean b): Append the string representation of the boolean parameter to the sequence .
Append(char c): Appends the string representation of the char parameter to this sequence.
Append(char[] str): Appends the string representation of the char array parameter to this sequence.
Append(char[] str, int offset, int len): Appends the string representation of the subarray of the char array parameter to this sequence.
Append(CharSequence s): Appends the specified character sequence to this Appendable.
Append(CharSequence s, int start, int end): Append the subsequence of the specified CharSequence to this sequence.
Append(double d): Appends the string representation of the double parameter to this sequence.
Append(float f): Appends the string representation of the float parameter to this sequence.
Append(int i): Appends the string representation of the int parameter to this sequence.
Append(long lng): Appends the string representation of the long parameter to this sequence.
Append(Object obj): Append the string representation of the Object parameter.
Append(String str): Append the specified string to this character sequence.
Append(StringBuffer sb): Append the specified StringBuffer to this sequence.
appendCodePoint(int codePoint): Appends the string representation of the codePoint parameter to this sequence.
capacity(): Returns the current capacity.
charAt(int index): Returns the char value at the specified index in this sequence.
codePointAt(int index): Returns the character (unified code point) at the specified index.
codePointBefore(int index): Returns the character before the specified index (unified code point).
codePointCount(int beginIndex, int endIndex): Returns the unified code points within the specified text range of this sequence.
Delete(int start, int end): Remove characters from the substring of this sequence.
deleteCharAt(int index): Remove the char at the specified position in this sequence.
ensureCapacity(int minimumCapacity): Ensure that the capacity is at least equal to the specified minimum value.
getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin): Copy characters from this sequence to the target character array dst.
IndexOf(String str): Returns the index of the first occurrence of the specified substring in the string.
IndexOf(String str, int fromIndex): Starting from the specified index, return the index of the first occurrence of the specified substring in the string.
insert(int offset, boolean b): Insert the string representation of the boolean parameter into this sequence.
insert(int offset, char c): Inserts the string representation of the char parameter into this sequence.
insert(int offset, char[] str): Inserts the string representation of the char array parameter into this sequence.
insert(int index, char[] str, int offset, int len): Insert the string representation of the array parameter str subarray into this sequence.
insert(int dstOffset, CharSequence s): Insert the specified CharSequence into this sequence.
insert(int dstOffset, CharSequence s, int start, int end): Insert the subsequence of the specified CharSequence into this sequence.
insert(int offset, double d): Insert the string representation of the double parameter into this sequence.
insert(int offset, float f): Inserts the string representation of the float parameter into this sequence.
insert(int offset, int i): Inserts the string representation of the int parameter into this sequence.
insert(int offset, long l): Insert the string representation of the long parameter into this sequence.
insert(int offset, Object obj): Insert the string representation of the Object parameter into this character sequence.
insert(int offset, String str): Insert a string into this character sequence.
lastIndexOf(String str): Returns the index of the rightmost specified substring in this string.
lastIndexOf(String str, int fromIndex): Returns the index of the last occurrence of the specified substring in this string.
length(): Returns the length (number of characters).
offsetByCodePoints(int index, int codePointOffset): Returns an index in this sequence that is offset by codePointOffset code points from the given index.
Replace(int start, int end, String str): Replace the characters in the substring of this sequence with the characters in the given String.
Reverse(): Replace this character sequence with its reversed form.
setCharAt(int index, char ch): Sets the character at the given index to ch.
setLength(int newLength): Set the length of the character sequence.
subSequence(int start, int end): Returns a new character sequence that is a subsequence of this sequence.
substring(int start): Returns a new String that contains the subsequence of characters currently contained in this character sequence.
Substring(int start, int end): Returns a new String that contains a subsequence of characters currently contained in this sequence.
toString(): Returns the string representation of the data in this sequence.
trimToSize(): Try to reduce the storage space used for character sequences.
The above is the detailed content of Important methods in StringBuilder class. For more information, please follow other related articles on the PHP Chinese website!