StringBuilder (Java SE 24 & JDK 24)
- All Implemented Interfaces:
Serializable,Appendable,CharSequence,Comparable<StringBuilder>
-
Constructor Summary
Constructors
Constructs a string builder with no characters in it and an initial capacity of 16 characters.
StringBuilder(int capacity) Constructs a string builder with no characters in it and an initial capacity specified by the
capacityargument.Constructs a string builder that contains the same characters as the specified
CharSequence.Constructs a string builder initialized to the contents of the specified string.
-
Method Summary
append(boolean b) Appends the string representation of the
booleanargument to the sequence.append(char c) Appends the string representation of the
charargument to this sequence.append(char[] str) Appends the string representation of the
chararray argument to this sequence.append(char[] str, int offset, int len) Appends the string representation of a subarray of the
chararray argument to this sequence.append(double d) Appends the string representation of the
doubleargument to this sequence.append(float f) Appends the string representation of the
floatargument to this sequence.append(int i) Appends the string representation of the
intargument to this sequence.append(long lng) Appends the string representation of the
longargument to this sequence.Appends the specified character sequence to this
Appendable.Appends a subsequence of the specified
CharSequenceto this sequence.Appends the string representation of the
Objectargument.Appends the specified string to this character sequence.
Appends the specified
StringBufferto this sequence.appendCodePoint(int codePoint) Appends the string representation of the
codePointargument to this sequence.intcapacity()Returns the current capacity.
charcharAt(int index) Returns the
charvalue in this sequence at the specified index.chars()Returns a stream of
intzero-extending thecharvalues from this sequence.intcodePointAt(int index) Returns the character (Unicode code point) at the specified index.
intcodePointBefore(int index) Returns the character (Unicode code point) before the specified index.
intcodePointCount(int beginIndex, int endIndex) Returns the number of Unicode code points in the specified text range of this sequence.
Returns a stream of code point values from this sequence.
intCompares two
StringBuilderinstances lexicographically.delete(int start, int end) Removes the characters in a substring of this sequence.
deleteCharAt(int index) Removes the
charat the specified position in this sequence.voidensureCapacity(int minimumCapacity) Ensures that the capacity is at least equal to the specified minimum.
voidgetChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) Characters are copied from this sequence into the destination character array
dst.intReturns the index within this string of the first occurrence of the specified substring.
intindexOf(String str, int fromIndex) Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
insert(int offset, boolean b) Inserts the string representation of the
booleanargument into this sequence.insert(int offset, char c) Inserts the string representation of the
charargument into this sequence.insert(int offset, char[] str) Inserts the string representation of the
chararray argument into this sequence.insert(int index, char[] str, int offset, int len) Inserts the string representation of a subarray of the
strarray argument into this sequence.insert(int offset, double d) Inserts the string representation of the
doubleargument into this sequence.insert(int offset, float f) Inserts the string representation of the
floatargument into this sequence.insert(int offset, int i) Inserts the string representation of the second
intargument into this sequence.insert(int offset, long l) Inserts the string representation of the
longargument into this sequence.Inserts the specified
CharSequenceinto this sequence.insert(int dstOffset, CharSequence s, int start, int end) Inserts a subsequence of the specified
CharSequenceinto this sequence.Inserts the string representation of the
Objectargument into this character sequence.Inserts the string into this character sequence.
intReturns the index within this string of the last occurrence of the specified substring.
intlastIndexOf(String str, int fromIndex) Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.
intlength()Returns the length (character count).
intoffsetByCodePoints(int index, int codePointOffset) Returns the index within this sequence that is offset from the given
indexbycodePointOffsetcode points.repeat(int codePoint, int count) Repeats
countcopies of the string representation of thecodePointargument to this sequence.Appends
countcopies of the specifiedCharSequencecsto this sequence.replace(int start, int end, String str) Replaces the characters in a substring of this sequence with characters in the specified
String.reverse()Causes this character sequence to be replaced by the reverse of the sequence.
voidsetCharAt(int index, char ch) The character at the specified index is set to
ch.voidsetLength(int newLength) Sets 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
Stringthat contains a subsequence of characters currently contained in this character sequence.substring(int start, int end) Returns a new
Stringthat contains a subsequence of characters currently contained in this sequence.toString()Returns a string representing the data in this sequence.
voidAttempts to reduce storage used for the character sequence.
-
Constructor Details
-
StringBuilder
-
StringBuilder
-
StringBuilder
-
StringBuilder
-
-
Method Details
-
compareTo
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
appendCodePoint
-
delete
-
deleteCharAt
-
replace
-
insert
-
insert
-
insert
-
insert
-
insert
-
insert
-
insert
-
insert
-
insert
-
insert
-
insert
-
insert
-
indexOf
-
indexOf
-
lastIndexOf
-
lastIndexOf
-
reverse
-
repeat
-
repeat
-
toString
-
length
-
capacity
-
ensureCapacity
-
trimToSize
-
setLength
-
charAt
-
codePointAt
-
codePointBefore
-
codePointCount
-
offsetByCodePoints
-
getChars
-
setCharAt
-
substring
-
subSequence
-
substring
-
chars
-
codePoints
-