java.lang.Objectjava.lang.AbstractStringBuilder
java.lang.StringBuilder
All Implemented Interfaces:
CharSequence, Serializable, Appendable
StringBuffer, but with no guarantee of synchronization.
This class is designed for use as a drop-in replacement for
StringBuffer in places where the string buffer was being
used by a single thread (as is generally the case). Where possible,
it is recommended that this class be used in preference to
StringBuffer as it will be faster under most implementations.
The principal operations on a StringBuilder are the
append and insert methods, which are
overloaded so as to accept data of any type. Each effectively
converts a given datum to a string and then appends or inserts the
characters of that string to the string builder. The
append method always adds these characters at the end
of the builder; the insert method adds the characters at
a specified point.
For example, if z refers to a string builder object
whose current contents are "start", then
the method call z.append("le") would cause the string
builder to contain "startle", whereas
z.insert(4, "le") would alter the string builder to
contain "starlet".
In general, if sb refers to an instance of a StringBuilder,
then sb.append(x) has the same effect as
sb.insert(sb.length(), x).
Every string builder has a capacity. As long as the length of the
character sequence contained in the string builder does not exceed
the capacity, it is not necessary to allocate a new internal
buffer. If the internal buffer overflows, it is automatically made larger.
Instances of StringBuilder are not safe for
use by multiple threads. If such synchronization is required then it is
recommended that java.lang.StringBuffer be used.
Michael - McCloskey1.5 - | Field Summary | ||
|---|---|---|
| static final long | serialVersionUID | use serialVersionUID for interoperability |
| Fields inherited from java.lang.AbstractStringBuilder: |
|---|
| value, count |
| Constructor: |
|---|
|
capacity argument.
|
16 plus the length of the string argument.
|
CharSequence. The initial capacity of
the string builder is 16 plus the length of the
CharSequence argument.
|
| Method from java.lang.StringBuilder Summary: |
|---|
| append, append, append, append, append, append, append, append, append, append, append, append, append, appendCodePoint, delete, deleteCharAt, indexOf, indexOf, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, lastIndexOf, lastIndexOf, replace, reverse, toString |
| Methods from java.lang.AbstractStringBuilder: |
|---|
| append, append, append, append, append, append, append, append, append, append, append, append, append, appendCodePoint, capacity, charAt, codePointAt, codePointBefore, codePointCount, delete, deleteCharAt, ensureCapacity, expandCapacity, getChars, getValue, indexOf, indexOf, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, insert, lastIndexOf, lastIndexOf, length, offsetByCodePoints, replace, reverse, setCharAt, setLength, subSequence, substring, substring, toString, trimToSize |
| Methods from java.lang.Object: |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from java.lang.StringBuilder Detail: |
|---|
|
|
The characters of the StringBuffer argument are appended, in order, to this sequence, increasing the length of this sequence by the length of the argument. If sb is null, then the four characters "null" are appended to this sequence.
Let n be the length of this character sequence just prior to
execution of the append method. Then the character at index
k in the new character sequence is equal to the character at
index k in the old character sequence, if k is less than
n; otherwise, it is equal to the character at index k-n
in the argument |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|