# StringBuffer

public final class **StringBuffer** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html) [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) [Serializable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Serializable.html) [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) A thread-safe, mutable sequence of characters.
A string buffer is like a `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html`, but can be modified. At any
point in time it contains some particular sequence of characters, but
the length and content of the sequence can be changed through certain
method calls.


String buffers are safe for use by multiple threads. The methods
are synchronized where necessary so that all the operations on any
particular instance behave as if they occur in some serial order
that is consistent with the order of the method calls made by each of
the individual threads involved.


The principal operations on a `StringBuffer` 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 buffer. The
`append` method always adds these characters at the end
of the buffer; the `insert` method adds the characters at
a specified point.


For example, if `z` refers to a string buffer object
whose current contents are `"start"`, then
the method call `z.append("le")` would cause the string
buffer to contain `"startle"`, whereas
`z.insert(4, "le")` would alter the string buffer to
contain `"starlet"`.


In general, if sb refers to an instance of a `StringBuffer`,
then `sb.append(x)` has the same effect as
`sb.insert(sb.length(), x)`.


Whenever an operation occurs involving a source sequence (such as
appending or inserting from a source sequence), this class synchronizes
only on the string buffer performing the operation, not on the source.
Note that while `StringBuffer` is designed to be safe to use
concurrently from multiple threads, if the constructor or the
`append` or `insert` operation is passed a source sequence
that is shared across threads, the calling code must ensure
that the operation has a consistent and unchanging view of the source
sequence for the duration of the operation.
This could be satisfied by the caller holding a lock during the
operation's call, by using an immutable source sequence, or by not
sharing the source sequence across threads.


Every string buffer has a capacity. As long as the length of the
character sequence contained in the string buffer does not exceed
the capacity, it is not necessary to allocate a new internal
buffer array. If the internal buffer overflows, it is
automatically made larger.


Unless otherwise noted, passing a `null` argument to a constructor
or method in this class will cause a `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html` to be
thrown.


As of release JDK 5, this class has been supplemented with an equivalent
class designed for use by a single thread, `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuilder.html`. The
`StringBuilder` class should generally be used in preference to
this one, as it supports all of the same operations but it is faster, as
it performs no synchronization.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuilder.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html`

### Public Constructor Summary

|---|---|
|   | [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#StringBuffer())() Constructs a string buffer with no characters in it and an initial capacity of 16 characters. |
|   | [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#StringBuffer(int))(int capacity) Constructs a string buffer with no characters in it and the specified initial capacity. |
|   | [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#StringBuffer(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str) Constructs a string buffer initialized to the contents of the specified string. |
|   | [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#StringBuffer(java.lang.CharSequence))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) seq) Constructs a string buffer that contains the same characters as the specified `CharSequence`. |

### Public Method Summary

|---|---|
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(boolean))(boolean b) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(long))(long lng) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(char))(char c) Appends the specified character to this Appendable. |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(char[],%20int,%20int))(char\[\] str, int offset, int len) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(double))(double d) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(char[]))(char\[\] str) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(java.lang.StringBuffer))([StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) sb) Appends the specified `StringBuffer` to this sequence. |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(float))(float f) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(int))(int i) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(java.lang.CharSequence,%20int,%20int))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) s, int start, int end) Appends a subsequence of the specified character sequence to this Appendable. |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#append(java.lang.CharSequence))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) s) Appends the specified `CharSequence` to this sequence. |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [appendCodePoint](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#appendCodePoint(int))(int codePoint) |
| synchronized int | [capacity](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#capacity())() |
| synchronized char | [charAt](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#charAt(int))(int index) Returns the `char` value at the specified index. |
| synchronized int | [codePointAt](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#codePointAt(int))(int index) |
| synchronized int | [codePointBefore](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#codePointBefore(int))(int index) |
| synchronized int | [codePointCount](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#codePointCount(int,%20int))(int beginIndex, int endIndex) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [delete](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#delete(int,%20int))(int start, int end) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [deleteCharAt](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#deleteCharAt(int))(int index) |
| synchronized void | [ensureCapacity](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#ensureCapacity(int))(int minimumCapacity) |
| synchronized void | [getChars](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#getChars(int,%20int,%20char[],%20int))(int srcBegin, int srcEnd, char\[\] dst, int dstBegin) |
| int | [indexOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#indexOf(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str) |
| synchronized int | [indexOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#indexOf(java.lang.String,%20int))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str, int fromIndex) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20char[]))(int offset, char\[\] str) |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20float))(int offset, float f) |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20java.lang.CharSequence))(int dstOffset, [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) s) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20char))(int offset, char c) |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20long))(int offset, long l) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20char[],%20int,%20int))(int index, char\[\] str, int offset, int len) |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20int))(int offset, int i) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20java.lang.String))(int offset, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str) |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20double))(int offset, double d) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20java.lang.CharSequence,%20int,%20int))(int dstOffset, [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) s, int start, int end) |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20java.lang.Object))(int offset, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) |
| [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [insert](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#insert(int,%20boolean))(int offset, boolean b) |
| synchronized int | [lastIndexOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#lastIndexOf(java.lang.String,%20int))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str, int fromIndex) |
| int | [lastIndexOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#lastIndexOf(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s) |
| synchronized int | [length](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#length())() Returns the length of this character sequence. |
| synchronized int | [offsetByCodePoints](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#offsetByCodePoints(int,%20int))(int index, int codePointOffset) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [replace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#replace(int,%20int,%20java.lang.String))(int start, int end, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str) |
| synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) | [reverse](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#reverse())() |
| synchronized void | [setCharAt](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#setCharAt(int,%20char))(int index, char ch) |
| synchronized void | [setLength](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#setLength(int))(int newLength) |
| synchronized [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) | [subSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#subSequence(int,%20int))(int start, int end) Returns a `CharSequence` that is a subsequence of this sequence. |
| synchronized [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [substring](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#substring(int,%20int))(int start, int end) |
| synchronized [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [substring](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#substring(int))(int start) |
| synchronized [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| synchronized void | [trimToSize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#trimToSize())() |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.lang.Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html)

|---|---|
| abstract [Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html#append(char))(char c) Appends the specified character to this Appendable. |
| abstract [Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html#append(java.lang.CharSequence,%20int,%20int))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) csq, int start, int end) Appends a subsequence of the specified character sequence to this Appendable. |
| abstract [Appendable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html) | [append](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Appendable.html#append(java.lang.CharSequence))([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) csq) Appends the specified character sequence to this Appendable. |

From interface [java.lang.CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html)

|---|---|
| abstract char | [charAt](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html#charAt(int))(int index) Returns the `char` value at the specified index. |
| [IntStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/IntStream.html) | [chars](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html#chars())() Returns a stream of `int` zero-extending the `char` values from this sequence. |
| [IntStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/IntStream.html) | [codePoints](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html#codePoints())() Returns a stream of code point values from this sequence. |
| abstract int | [length](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html#length())() Returns the length of this character sequence. |
| abstract [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) | [subSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html#subSequence(int,%20int))(int start, int end) Returns a `CharSequence` that is a subsequence of this sequence. |
| abstract [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html#toString())() Returns a string containing the characters in this sequence in the same order as this sequence. |

## Public Constructors

#### public
**StringBuffer**
()

Constructs a string buffer with no characters in it and an
initial capacity of 16 characters.

#### public
**StringBuffer**
(int capacity)

Constructs a string buffer with no characters in it and
the specified initial capacity.

##### Parameters

| capacity | the initial capacity. |
|---|---|

##### Throws

| [NegativeArraySizeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NegativeArraySizeException.html) | if the `capacity` argument is less than `0`. |
|---|---|

#### public
**StringBuffer**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str)

Constructs a string buffer initialized to the contents of the
specified string. The initial capacity of the string buffer is
`16` plus the length of the string argument.

##### Parameters

| str | the initial contents of the buffer. |
|---|---|

#### public
**StringBuffer**
([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) seq)

Constructs a string buffer that contains the same characters
as the specified `CharSequence`. The initial capacity of
the string buffer is `16` plus the length of the
`CharSequence` argument.


If the length of the specified `CharSequence` is
less than or equal to zero, then an empty buffer of capacity
`16` is returned.

##### Parameters

| seq | the sequence to copy. |
|---|---|

## Public Methods

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
(boolean b)

<br />

##### Parameters

| b |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
(long lng)

<br />

##### Parameters

| lng |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
(char c)

Appends the specified character to this Appendable.

##### Parameters

| c | The character to append |
|---|---|

##### Returns

- A reference to this Appendable

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj)

<br />

##### Parameters

| obj |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
(char\[\] str, int offset, int len)

<br />

##### Parameters

| str |   |
| offset |   |
| len |   |
|---|---|

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
(double d)

<br />

##### Parameters

| d |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
(char\[\] str)

<br />

##### Parameters

| str |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str)

<br />

##### Parameters

| str |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
([StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html) sb)

Appends the specified `StringBuffer` to this sequence.


The characters of the `StringBuffer` argument are appended,
in order, to the contents of this `StringBuffer`, increasing the
length of this `StringBuffer` by the length of the argument.
If `sb` is `null`, then the four characters
`"null"` are appended to this `StringBuffer`.


Let *n* be the length of the old character sequence, the one
contained in the `StringBuffer` 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 `sb`.


This method synchronizes on `this`, the destination
object, but does not synchronize on the source (`sb`).

##### Parameters

| sb | the `StringBuffer` to append. |
|---|---|

##### Returns

- a reference to this object.

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
(float f)

<br />

##### Parameters

| f |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
(int i)

<br />

##### Parameters

| i |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) s, int start, int end)

Appends a subsequence of the specified character sequence to this
Appendable.

An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in
exactly the same way as the invocation

```
     out.append(csq.subSequence(start, end)) 
```

<br />

##### Parameters

| s | The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null". |
| start | The index of the first character in the subsequence |
| end | The index of the character following the last character in the subsequence |
|---|---|

##### Returns

- A reference to this Appendable

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**append**
([CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) s)

Appends the specified `CharSequence` to this
sequence.


The characters of the `CharSequence` argument are appended,
in order, increasing the length of this sequence by the length of the
argument.

The result of this method is exactly the same as if it were an
invocation of this.append(s, 0, s.length());

This method synchronizes on `this`, the destination
object, but does not synchronize on the source (`s`).

If `s` is `null`, then the four characters
`"null"` are appended.

##### Parameters

| s | the `CharSequence` to append. |
|---|---|

##### Returns

- a reference to this object.

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**appendCodePoint**
(int codePoint)

<br />

##### Parameters

| codePoint |   |
|---|---|

#### public synchronized int
**capacity**
()

<br />

#### public synchronized char
**charAt**
(int index)

Returns the `char` value at the specified index. An index ranges from zero
to length() - 1. The first `char` value of the sequence is at
index zero, the next at index one, and so on, as for array
indexing.

If the `char` value specified by the index is a
[surrogate](https://developers.google.com/j2objc/javadoc/jre//java/lang/Character.html#unicode), the surrogate
value is returned.

##### Parameters

| index | the index of the `char` value to be returned |
|---|---|

##### Returns

- the specified `char` value

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#length()`

#### public synchronized int
**codePointAt**
(int index)

<br />

##### Parameters

| index |   |
|---|---|

#### public synchronized int
**codePointBefore**
(int index)

<br />

##### Parameters

| index |   |
|---|---|

#### public synchronized int
**codePointCount**
(int beginIndex, int endIndex)

<br />

##### Parameters

| beginIndex |   |
| endIndex |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**delete**
(int start, int end)

<br />

##### Parameters

| start |   |
| end |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**deleteCharAt**
(int index)

<br />

##### Parameters

| index |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized void
**ensureCapacity**
(int minimumCapacity)

<br />

##### Parameters

| minimumCapacity |   |
|---|---|

#### public synchronized void
**getChars**
(int srcBegin, int srcEnd, char\[\] dst, int dstBegin)

<br />

##### Parameters

| srcBegin |   |
| srcEnd |   |
| dst |   |
| dstBegin |   |
|---|---|

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

#### public int
**indexOf**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str)

<br />

##### Parameters

| str |   |
|---|---|

#### public synchronized int
**indexOf**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str, int fromIndex)

<br />

##### Parameters

| str |   |
| fromIndex |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, char\[\] str)

<br />

##### Parameters

| offset |   |
| str |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, float f)

<br />

##### Parameters

| offset |   |
| f |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int dstOffset, [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) s)

<br />

##### Parameters

| dstOffset |   |
| s |   |
|---|---|

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, char c)

<br />

##### Parameters

| offset |   |
| c |   |
|---|---|

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, long l)

<br />

##### Parameters

| offset |   |
| l |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int index, char\[\] str, int offset, int len)

<br />

##### Parameters

| index |   |
| str |   |
| offset |   |
| len |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, int i)

<br />

##### Parameters

| offset |   |
| i |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str)

<br />

##### Parameters

| offset |   |
| str |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, double d)

<br />

##### Parameters

| offset |   |
| d |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int dstOffset, [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html) s, int start, int end)

<br />

##### Parameters

| dstOffset |   |
| s |   |
| start |   |
| end |   |
|---|---|

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj)

<br />

##### Parameters

| offset |   |
| obj |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**insert**
(int offset, boolean b)

<br />

##### Parameters

| offset |   |
| b |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized int
**lastIndexOf**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str, int fromIndex)

<br />

##### Parameters

| str |   |
| fromIndex |   |
|---|---|

#### public int
**lastIndexOf**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s)

<br />

##### Parameters

| s |   |
|---|---|

#### public synchronized int
**length**
()

Returns the length of this character sequence. The length is the number
of 16-bit `char`s in the sequence.

##### Returns

- the number of `char`s in this sequence

#### public synchronized int
**offsetByCodePoints**
(int index, int codePointOffset)

<br />

##### Parameters

| index |   |
| codePointOffset |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**replace**
(int start, int end, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) str)

<br />

##### Parameters

| start |   |
| end |   |
| str |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [StringBuffer](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html)
**reverse**
()

<br />

#### public synchronized void
**setCharAt**
(int index, char ch)

<br />

##### Parameters

| index |   |
| ch |   |
|---|---|

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#length()`

#### public synchronized void
**setLength**
(int newLength)

<br />

##### Parameters

| newLength |   |
|---|---|

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringBuffer.html#length()`

#### public synchronized [CharSequence](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/CharSequence.html)
**subSequence**
(int start, int end)

Returns a `CharSequence` that is a subsequence of this sequence.
The subsequence starts with the `char` value at the specified index and
ends with the `char` value at index end - 1. The length
(in `char`s) of the
returned sequence is end - start, so if start == end
then an empty sequence is returned.

##### Parameters

| start | the start index, inclusive |
| end | the end index, exclusive |
|---|---|

##### Returns

- the specified subsequence

##### Throws

| [IndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**substring**
(int start, int end)

<br />

##### Parameters

| start |   |
| end |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**substring**
(int start)

<br />

##### Parameters

| start |   |
|---|---|

##### Throws

| [StringIndexOutOfBoundsException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/StringIndexOutOfBoundsException.html) |   |
|---|---|

#### public synchronized [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Returns a string containing a concise, human-readable description of this
object. Subclasses are encouraged to override this method and provide an
implementation that takes into account the object's type and data. The
default implementation is equivalent to the following expression:

```
   getClass().getName() + '@' + Integer.toHexString(hashCode())
```

See [Writing a useful
`toString` method](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#writing_toString)
if you intend implementing your own `toString` method.

##### Returns

- a printable representation of this object.

#### public synchronized void
**trimToSize**
()

<br />