Java Reference
In-Depth Information
CONSTRUCTORS
public
StringBuffer()
Creates a
StringBuffer
object with no characters in it and an initial capacity of 16 characters.
public
StringBuffer(
int
capacity)
Constructs a
StringBuffer
object with no characters in it and an initial capacity specifi ed by
the argument.
Throws:
NegativeArraySizeException
if
length
is less than 0.
NegativeArraySizeException
is a derived class of
RuntimeException,
and so is an unchecked exception, which means it is
not required to be caught or declared in a
throws
clause.
public
StringBuffer(String ordinaryString)
Constructs a string buffer so that it represents the same sequence of characters as the
ordinaryString
argument; in other words, the initial content of the string buffer is a copy of
ordinaryString
. The initial capacity of the string buffer is 16 plus the length of
ordinaryString
.
Throws:
NullPointerException
if
ordinaryString
is
null.
METHODS
public
StringBuffer append(
char
[] charArray,
int
offset,
int
length)
Appends the string representation of the characters in
charArray
starting at
charArray[offset]
and extending for a total of
length
characters. Note that the calling object
is changed and a reference to the changed calling object is returned.
Throws:
ArrayIndexOutOfBoundsException
if
offset
and
length
are not consistent with the
range of
charArray
.
public
StringBuffer append(
char
c)
Appends the character argument to the
StringBuffer
calling object and returns this longer
string.
public
StringBuffer append(
char
[] charArray)
Appends the string representation of the
char
array argument to this string buffer. Note that the
calling object is changed and a reference to the changed calling object is returned.
public
StringBuffer append(
double
d)
Appends the string representation of the
double
argument to the
StringBuffer
calling object
and returns this longer string.
public
StringBuffer append(
float
d)
Appends the string representation of the
float
argument to the
StringBuffer
calling object
and returns this longer string.