public final class StringBuffer extends Object implements CharSequence
Constructor and Description |
---|
StringBuffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
|
StringBuffer(int length)
Constructs a string buffer with no characters in it and an initial capacity specified by the length argument.
|
StringBuffer(String str)
Constructs a string buffer so that it represents the same sequence of characters as the string argument; in other words, the initial contents of the string buffer is a copy of the argument string.
|
Modifier and Type | Method and Description |
---|---|
StringBuffer |
append(boolean b)
Appends the string representation of the boolean argument to the string buffer.
|
StringBuffer |
append(char c)
Appends the string representation of the char argument to this string buffer.
|
StringBuffer |
append(char[] str,
int offset,
int len)
Appends the string representation of a subarray of the char array argument to this string buffer.
|
StringBuffer |
append(CharSequence cs) |
StringBuffer |
append(CharSequence cs,
int start,
int end) |
StringBuffer |
append(double d)
Appends the string representation of the double argument to this string buffer.
|
StringBuffer |
append(float f)
Appends the string representation of the float argument to this string buffer.
|
StringBuffer |
append(int i)
Appends the string representation of the int argument to this string buffer.
|
StringBuffer |
append(long l)
Appends the string representation of the long argument to this string buffer.
|
StringBuffer |
append(Object obj)
Appends the string representation of the Object argument to this string buffer.
|
StringBuffer |
append(String str)
Appends the string to this string buffer.
|
int |
capacity()
Returns the current capacity of the String buffer.
|
char |
charAt(int index)
The specified character of the sequence currently represented by the string buffer, as indicated by the index argument, is returned.
|
StringBuffer |
delete(int start,
int end)
Removes the characters in a substring of this StringBuffer.
|
StringBuffer |
deleteCharAt(int index)
Removes the character at the specified position in this StringBuffer (shortening the StringBuffer by one character).
|
void |
ensureCapacity(int minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum.
|
void |
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Characters are copied from this string buffer into the destination character array dst.
|
StringBuffer |
insert(int offset,
boolean b)
Inserts the string representation of the boolean argument into this string buffer.
|
StringBuffer |
insert(int offset,
char c)
Inserts the string representation of the char argument into this string buffer.
|
StringBuffer |
insert(int offset,
CharSequence cs) |
StringBuffer |
insert(int offset,
CharSequence cs,
int start,
int end) |
StringBuffer |
insert(int offset,
double d)
Inserts the string representation of the double argument into this string buffer.
|
StringBuffer |
insert(int offset,
float f)
Inserts the string representation of the float argument into this string buffer.
|
StringBuffer |
insert(int offset,
int i)
Inserts the string representation of the second int argument into this string buffer.
|
StringBuffer |
insert(int offset,
long l)
Inserts the string representation of the long argument into this string buffer.
|
StringBuffer |
insert(int offset,
Object obj)
Inserts the string representation of the Object argument into this string buffer.
|
StringBuffer |
insert(int offset,
String str)
Inserts the string into this string buffer.
|
int |
length()
Returns the length (character count) of this string buffer.
|
StringBuffer |
reverse()
The character sequence contained in this string buffer is replaced by the reverse of the sequence.
|
void |
setCharAt(int index,
char ch)
The character at the specified index of this string buffer is set to ch.
|
void |
setLength(int newLength)
Sets the length of this string buffer.
|
StringBuffer |
StringBuffer(CharSequence cs) |
CharSequence |
subSequence(int start,
int end)
Returns a
CharSequence from the start index (inclusive)
to the end index (exclusive) of this sequence. |
String |
toString()
Converts to a string representing the data in this string buffer.
|
void |
trimToSize() |
public StringBuffer()
public StringBuffer(int length)
public StringBuffer(String str)
public StringBuffer append(boolean b)
public StringBuffer append(char c)
public StringBuffer append(char[] str, int offset, int len)
public StringBuffer append(double d)
public StringBuffer append(float f)
public StringBuffer append(int i)
public StringBuffer append(long l)
public StringBuffer append(Object obj)
public StringBuffer append(String str)
public int capacity()
public char charAt(int index)
charAt
in interface CharSequence
index
- the index of the character to return.public StringBuffer delete(int start, int end)
public StringBuffer deleteCharAt(int index)
public void ensureCapacity(int minimumCapacity)
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
public StringBuffer insert(int offset, boolean b)
public StringBuffer insert(int offset, char c)
public StringBuffer insert(int offset, double d)
public StringBuffer insert(int offset, float f)
public StringBuffer insert(int offset, int i)
public StringBuffer insert(int offset, long l)
public StringBuffer insert(int offset, Object obj)
public StringBuffer insert(int offset, String str)
public int length()
length
in interface CharSequence
public StringBuffer reverse()
public void setCharAt(int index, char ch)
public void setLength(int newLength)
public String toString()
toString
in interface CharSequence
toString
in class Object
public StringBuffer StringBuffer(CharSequence cs)
public void trimToSize()
public StringBuffer append(CharSequence cs)
public StringBuffer append(CharSequence cs, int start, int end)
public StringBuffer insert(int offset, CharSequence cs)
public StringBuffer insert(int offset, CharSequence cs, int start, int end)
public CharSequence subSequence(int start, int end)
CharSequence
CharSequence
from the start
index (inclusive)
to the end
index (exclusive) of this sequence.subSequence
in interface CharSequence
start
- the start offset of the sub-sequence. It is inclusive, that
is, the index of the first character that is included in the
sub-sequence.end
- the end offset of the sub-sequence. It is exclusive, that is,
the index of the first character after those that are included
in the sub-sequence