Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/java/lang/StringBuilder#pubctors) \| [Methods](https://developer.android.com/reference/java/lang/StringBuilder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/lang/StringBuilder#inhmethods)

# StringBuilder


`
public

final

class
StringBuilder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/java/lang/Appendable,

https://developer.android.com/reference/java/lang/CharSequence,

https://developer.android.com/reference/java/lang/Comparable<https://developer.android.com/reference/java/lang/StringBuilder>,

https://developer.android.com/reference/java/io/Serializable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.lang.StringBuilder |

<br />

*** ** * ** ***

A mutable sequence of characters. This class provides an API compatible
with `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 `https://developer.android.com/reference/java/lang/StringBuffer` be used.

Unless otherwise noted, passing a `null` argument to a constructor
or method in this class will cause a `https://developer.android.com/reference/java/lang/NullPointerException` to be
thrown.
**See also:**

- `https://developer.android.com/reference/java/lang/StringBuffer`
- `https://developer.android.com/reference/java/lang/String`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/lang/StringBuilder#StringBuilder()() ` Constructs a string builder with no characters in it and an initial capacity of 16 characters. |
| ` https://developer.android.com/reference/java/lang/StringBuilder#StringBuilder(int)(int capacity) ` Constructs a string builder with no characters in it and an initial capacity specified by the `capacity` argument. |
| ` https://developer.android.com/reference/java/lang/StringBuilder#StringBuilder(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence seq) ` Constructs a string builder that contains the same characters as the specified `CharSequence`. |
| ` https://developer.android.com/reference/java/lang/StringBuilder#StringBuilder(java.lang.String)(https://developer.android.com/reference/java/lang/String str) ` Constructs a string builder initialized to the contents of the specified string. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(boolean)(boolean b) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(long)(long lng) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(char)(char c) ` Appends the specified character to this `Appendable`. |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(char[],%20int,%20int)(char[] str, int offset, int len) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(double)(double d) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(char[])(char[] str) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(java.lang.String)(https://developer.android.com/reference/java/lang/String str) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(java.lang.StringBuffer)(https://developer.android.com/reference/java/lang/StringBuffer sb) ` Appends the specified `StringBuffer` to this sequence. |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(float)(float f) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(int)(int i) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(java.lang.CharSequence,%20int,%20int)(https://developer.android.com/reference/java/lang/CharSequence s, int start, int end) ` Appends a subsequence of the specified character sequence to this `Appendable`. |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#append(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Appends the specified character sequence to this `Appendable`. |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#appendCodePoint(int)(int codePoint) ` |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#capacity()() ` Returns the current capacity. |
| ` char` | ` https://developer.android.com/reference/java/lang/StringBuilder#charAt(int)(int index) ` Returns the `char` value in this sequence at the specified index. |
| ` https://developer.android.com/reference/java/util/stream/IntStream` | ` https://developer.android.com/reference/java/lang/StringBuilder#chars()() ` Returns a stream of `int` zero-extending the `char` values from this sequence. |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#codePointAt(int)(int index) ` Returns the character (Unicode code point) at the specified index. |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#codePointBefore(int)(int index) ` Returns the character (Unicode code point) before the specified index. |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#codePointCount(int,%20int)(int beginIndex, int endIndex) ` Returns the number of Unicode code points in the specified text range of this sequence. |
| ` https://developer.android.com/reference/java/util/stream/IntStream` | ` https://developer.android.com/reference/java/lang/StringBuilder#codePoints()() ` Returns a stream of code point values from this sequence. |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#compareTo(java.lang.StringBuilder)(https://developer.android.com/reference/java/lang/StringBuilder another) ` Compares two `StringBuilder` instances lexicographically. |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#delete(int,%20int)(int start, int end) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#deleteCharAt(int)(int index) ` |
| ` void` | ` https://developer.android.com/reference/java/lang/StringBuilder#ensureCapacity(int)(int minimumCapacity) ` Ensures that the capacity is at least equal to the specified minimum. |
| ` void` | ` https://developer.android.com/reference/java/lang/StringBuilder#getChars(int,%20int,%20char[],%20int)(int srcBegin, int srcEnd, char[] dst, int dstBegin) ` Copies characters from this sequence into the given destination array. |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#indexOf(java.lang.String)(https://developer.android.com/reference/java/lang/String str) ` |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#indexOf(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String str, int fromIndex) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20char[])(int offset, char[] str) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20float)(int offset, float f) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20java.lang.CharSequence)(int dstOffset, https://developer.android.com/reference/java/lang/CharSequence s) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20char)(int offset, char c) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20long)(int offset, long l) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20char[],%20int,%20int)(int index, char[] str, int offset, int len) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20int)(int offset, int i) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20java.lang.String)(int offset, https://developer.android.com/reference/java/lang/String str) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20double)(int offset, double d) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20java.lang.CharSequence,%20int,%20int)(int dstOffset, https://developer.android.com/reference/java/lang/CharSequence s, int start, int end) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20boolean)(int offset, boolean b) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#insert(int,%20java.lang.Object)(int offset, https://developer.android.com/reference/java/lang/Object obj) ` |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#lastIndexOf(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String str, int fromIndex) ` |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#lastIndexOf(java.lang.String)(https://developer.android.com/reference/java/lang/String str) ` |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#length()() ` Returns the length (character count). |
| ` int` | ` https://developer.android.com/reference/java/lang/StringBuilder#offsetByCodePoints(int,%20int)(int index, int codePointOffset) ` Returns the index within this sequence that is offset from the given `index` by `codePointOffset` code points. |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#repeat(int,%20int)(int codePoint, int count) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#repeat(java.lang.CharSequence,%20int)(https://developer.android.com/reference/java/lang/CharSequence cs, int count) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#replace(int,%20int,%20java.lang.String)(int start, int end, https://developer.android.com/reference/java/lang/String str) ` |
| ` https://developer.android.com/reference/java/lang/StringBuilder` | ` https://developer.android.com/reference/java/lang/StringBuilder#reverse()() ` |
| ` void` | ` https://developer.android.com/reference/java/lang/StringBuilder#setCharAt(int,%20char)(int index, char ch) ` The character at the specified index is set to `ch`. |
| ` void` | ` https://developer.android.com/reference/java/lang/StringBuilder#setLength(int)(int newLength) ` Sets the length of the character sequence. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/java/lang/StringBuilder#subSequence(int,%20int)(int start, int end) ` Returns a new character sequence that is a subsequence of this sequence. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/StringBuilder#substring(int,%20int)(int start, int end) ` Returns a new `String` that contains a subsequence of characters currently contained in this sequence. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/StringBuilder#substring(int)(int start) ` Returns a new `String` that contains a subsequence of characters currently contained in this character sequence. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/StringBuilder#toString()() ` Returns a string representation of the object. |
| ` void` | ` https://developer.android.com/reference/java/lang/StringBuilder#trimToSize()() ` Attempts to reduce storage used for the character sequence. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


From interface `

https://developer.android.com/reference/java/lang/Appendable

` `
abstract


https://developer.android.com/reference/java/lang/Appendable` `
https://developer.android.com/reference/java/lang/Appendable#append(char)(char c)
`

Appends the specified character to this `Appendable`.


`
abstract


https://developer.android.com/reference/java/lang/Appendable` `
https://developer.android.com/reference/java/lang/Appendable#append(java.lang.CharSequence,%20int,%20int)(https://developer.android.com/reference/java/lang/CharSequence csq, int start, int end)
`

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


`
abstract


https://developer.android.com/reference/java/lang/Appendable` `
https://developer.android.com/reference/java/lang/Appendable#append(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence csq)
`

Appends the specified character sequence to this `Appendable`.


From interface `

https://developer.android.com/reference/java/lang/CharSequence

` `
abstract


char` `
https://developer.android.com/reference/java/lang/CharSequence#charAt(int)(int index)
`

Returns the `char` value at the specified index.


`

default


https://developer.android.com/reference/java/util/stream/IntStream` `
https://developer.android.com/reference/java/lang/CharSequence#chars()()
`

Returns a stream of `int` zero-extending the `char` values
from this sequence.


`

default


https://developer.android.com/reference/java/util/stream/IntStream` `
https://developer.android.com/reference/java/lang/CharSequence#codePoints()()
`

Returns a stream of code point values from this sequence.


`


static


int` `
https://developer.android.com/reference/java/lang/CharSequence#compare(java.lang.CharSequence,%20java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence cs1, https://developer.android.com/reference/java/lang/CharSequence cs2)
`

Compares two `CharSequence` instances lexicographically.


`

default


void` `
https://developer.android.com/reference/java/lang/CharSequence#getChars(int,%20int,%20char[],%20int)(int srcBegin, int srcEnd, char[] dst, int dstBegin)
`

Copies characters from this sequence into the given destination array.


`

default


boolean` `
https://developer.android.com/reference/java/lang/CharSequence#isEmpty()()
`

Returns `true` if this character sequence is empty.


`
abstract


int` `
https://developer.android.com/reference/java/lang/CharSequence#length()()
`

Returns the length of this character sequence.


`
abstract


https://developer.android.com/reference/java/lang/CharSequence` `
https://developer.android.com/reference/java/lang/CharSequence#subSequence(int,%20int)(int start, int end)
`

Returns a `CharSequence` that is a subsequence of this sequence.


`
abstract


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/CharSequence#toString()()
`

Returns a string containing the characters in this sequence in the same
order as this sequence.


From interface `

https://developer.android.com/reference/java/lang/Comparable

` `
abstract


int` `
https://developer.android.com/reference/java/lang/Comparable#compareTo(T)(https://developer.android.com/reference/java/lang/StringBuilder o)
`

Compares this object with the specified object for order.


## Public constructors

### StringBuilder

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder ()
```

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

<br />

### StringBuilder

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder (int capacity)
```

Constructs a string builder with no characters in it and an
initial capacity specified by the `capacity` argument.

<br />

| Parameters ||
|---|---|
| `capacity` | `int`: the initial capacity. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NegativeArraySizeException` | if the `capacity` argument is less than `0`. |

### StringBuilder

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder (CharSequence seq)
```

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

<br />

| Parameters ||
|---|---|
| `seq` | `CharSequence`: the sequence to copy. <br /> |

### StringBuilder

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder (String str)
```

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

<br />

| Parameters ||
|---|---|
| `str` | `String`: the initial contents of the buffer. <br /> |

## Public methods

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (boolean b)
```

<br />

<br />

| Parameters ||
|---|---|
| `b` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (long lng)
```

<br />

<br />

| Parameters ||
|---|---|
| `lng` | `long` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (char c)
```

Appends the specified character to this `Appendable`.

<br />

| Parameters ||
|---|---|
| `c` | `char`: The character to append <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | A reference to this `Appendable` <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (Object obj)
```

<br />

<br />

| Parameters ||
|---|---|
| `obj` | `Object` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (char[] str, 
                int offset, 
                int len)
```

<br />

<br />

| Parameters ||
|---|---|
| `str` | `char` <br /> |
| `offset` | `int` <br /> |
| `len` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` |   |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (double d)
```

<br />

<br />

| Parameters ||
|---|---|
| `d` | `double` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (char[] str)
```

<br />

<br />

| Parameters ||
|---|---|
| `str` | `char` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (String str)
```

<br />

<br />

| Parameters ||
|---|---|
| `str` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (StringBuffer sb)
```

Appends the specified `StringBuffer` to this sequence.


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 `sb`.

<br />

| Parameters ||
|---|---|
| `sb` | `StringBuffer`: the `StringBuffer` to append. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | a reference to this object. <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (float f)
```

<br />

<br />

| Parameters ||
|---|---|
| `f` | `float` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (int i)
```

<br />

<br />

| Parameters ||
|---|---|
| `i` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (CharSequence 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 />

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: 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"`. <br /> |
| `start` | `int`: The index of the first character in the subsequence <br /> |
| `end` | `int`: The index of the character following the last character in the subsequence <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | A reference to this `Appendable` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` |   |

### append

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder append (CharSequence s)
```

Appends the specified character sequence to this `Appendable`.

Depending on which class implements the character sequence
`csq`, the entire sequence may not be appended. For
instance, if `csq` is a `https://developer.android.com/reference/java/nio/CharBuffer` then
the subsequence to append is defined by the buffer's position and limit.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: The character sequence to append. If `csq` is `null`, then the four characters `"null"` are appended to this Appendable. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | A reference to this `Appendable` <br /> |

### appendCodePoint

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder appendCodePoint (int codePoint)
```

<br />

<br />

| Parameters ||
|---|---|
| `codePoint` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### capacity

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int capacity ()
```

Returns the current capacity. The capacity is the amount of storage
available for newly inserted characters, beyond which an allocation
will occur.

<br />

| Returns ||
|---|---|
| `int` | the current capacity <br /> |

### charAt

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public char charAt (int index)
```

Returns the `char` value in this sequence at the specified index.
The first `char` value is at index `0`, the next at index
`1`, and so on, as in array indexing.


The index argument must be greater than or equal to
`0`, and less than the length of this sequence.

If the `char` value specified by the index is a
[surrogate](https://developer.android.com/reference/java/lang/Character#unicode), the surrogate
value is returned.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the desired `char` value. <br /> |

| Returns ||
|---|---|
| `char` | the `char` value at the specified index. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `index` is negative or greater than or equal to `length()`. |

### chars

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public IntStream chars ()
```

Returns a stream of `int` zero-extending the `char` values
from this sequence. Any char which maps to a [surrogate code
point](https://reference/java/lang/Character.html#unicode) is passed through uninterpreted.

The stream binds to this sequence when the terminal stream operation
commences (specifically, for mutable sequences the spliterator for the
stream is [*late-binding*](https://developer.android.com/reference/java/util/Spliterator.html#binding)).
If the sequence is modified during that operation then the result is
undefined.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/stream/IntStream` | an IntStream of char values from this sequence <br /> |

### codePointAt

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int codePointAt (int index)
```

Returns the character (Unicode code point) at the specified
index. The index refers to `char` values
(Unicode code units) and ranges from `0` to
`https://developer.android.com/reference/java/lang/StringBuilder#length()``- 1`.

If the `char` value specified at the given index
is in the high-surrogate range, the following index is less
than the length of this sequence, and the
`char` value at the following index is in the
low-surrogate range, then the supplementary code point
corresponding to this surrogate pair is returned. Otherwise,
the `char` value at the given index is returned.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index to the `char` values <br /> |

| Returns ||
|---|---|
| `int` | the code point value of the character at the `index` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the `index` argument is negative or not less than the length of this sequence. |

### codePointBefore

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int codePointBefore (int index)
```

Returns the character (Unicode code point) before the specified
index. The index refers to `char` values
(Unicode code units) and ranges from `1` to `https://developer.android.com/reference/java/lang/StringBuilder#length()`.

If the `char` value at `(index - 1)`
is in the low-surrogate range, `(index - 2)` is not
negative, and the `char` value at `(index -
2)` is in the high-surrogate range, then the
supplementary code point value of the surrogate pair is
returned. If the `char` value at `index -
1` is an unpaired low-surrogate or a high-surrogate, the
surrogate value is returned.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index following the code point that should be returned <br /> |

| Returns ||
|---|---|
| `int` | the Unicode code point value before the given index. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the `index` argument is less than 1 or greater than the length of this sequence. |

### codePointCount

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int codePointCount (int beginIndex, 
                int endIndex)
```

Returns the number of Unicode code points in the specified text
range of this sequence. The text range begins at the specified
`beginIndex` and extends to the `char` at
index `endIndex - 1`. Thus the length (in
`char`s) of the text range is
`endIndex-beginIndex`. Unpaired surrogates within
this sequence count as one code point each.

<br />

| Parameters ||
|---|---|
| `beginIndex` | `int`: the index to the first `char` of the text range. <br /> |
| `endIndex` | `int`: the index after the last `char` of the text range. <br /> |

| Returns ||
|---|---|
| `int` | the number of Unicode code points in the specified text range <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the `beginIndex` is negative, or `endIndex` is larger than the length of this sequence, or `beginIndex` is larger than `endIndex`. |

### codePoints

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public IntStream codePoints ()
```

Returns a stream of code point values from this sequence. Any surrogate
pairs encountered in the sequence are combined as if by [Character.toCodePoint](https://developer.android.com/reference/java/lang/Character#toCodePoint(char,%20char)) and the result is passed
to the stream. Any other code units, including ordinary BMP characters,
unpaired surrogates, and undefined code units, are zero-extended to
`int` values which are then passed to the stream.

The stream binds to this sequence when the terminal stream operation
commences (specifically, for mutable sequences the spliterator for the
stream is [*late-binding*](https://developer.android.com/reference/java/util/Spliterator.html#binding)).
If the sequence is modified during that operation then the result is
undefined.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/stream/IntStream` | an IntStream of Unicode code points from this sequence <br /> |

### compareTo

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int compareTo (StringBuilder another)
```

Compares two `StringBuilder` instances lexicographically. This method
follows the same rules for lexicographical comparison as defined in the
[CharSequence.compare(this, another)](https://developer.android.com/reference/java/lang/CharSequence#compare(java.lang.CharSequence,%20java.lang.CharSequence)) method.


For finer-grained, locale-sensitive String comparison, refer to
`https://developer.android.com/reference/java/text/Collator`.

<br />

| Parameters ||
|---|---|
| `another` | `StringBuilder`: the `StringBuilder` to be compared with <br /> |

| Returns ||
|---|---|
| `int` | the value `0` if this `StringBuilder` contains the same character sequence as that of the argument `StringBuilder`; a negative integer if this `StringBuilder` is lexicographically less than the `StringBuilder` argument; or a positive integer if this `StringBuilder` is lexicographically greater than the `StringBuilder` argument. <br /> |

### delete

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder delete (int start, 
                int end)
```

<br />

<br />

| Parameters ||
|---|---|
| `start` | `int` <br /> |
| `end` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### deleteCharAt

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder deleteCharAt (int index)
```

<br />

<br />

| Parameters ||
|---|---|
| `index` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### ensureCapacity

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void ensureCapacity (int minimumCapacity)
```

Ensures that the capacity is at least equal to the specified minimum.
If the current capacity is less than the argument, then a new internal
array is allocated with greater capacity. The new capacity is the
larger of:

- The `minimumCapacity` argument.
- Twice the old capacity, plus `2`.

If the `minimumCapacity` argument is nonpositive, this method takes no action and simply returns. Note that subsequent operations on this object can reduce the actual capacity below that requested here.

<br />

<br />

| Parameters ||
|---|---|
| `minimumCapacity` | `int`: the minimum desired capacity. <br /> |

### getChars

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void getChars (int srcBegin, 
                int srcEnd, 
                char[] dst, 
                int dstBegin)
```

Copies characters from this sequence into the given destination array.
The first character to be copied is at index `srcBegin`; the last
character to be copied is at index `srcEnd-1`. The total number of
characters to be copied is `srcEnd-srcBegin`. The
characters are copied into the subarray of `dst` starting
at index `dstBegin` and ending at index:

    dstbegin + (srcEnd-srcBegin) - 1

<br />

<br />

| Parameters ||
|---|---|
| `srcBegin` | `int`: start copying at this offset. <br /> |
| `srcEnd` | `int`: stop copying at this offset. <br /> |
| `dst` | `char`: the array to copy the data into. <br /> |
| `dstBegin` | `int`: offset into `dst`. <br /> |

### indexOf

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int indexOf (String str)
```

<br />

<br />

| Parameters ||
|---|---|
| `str` | `String` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### indexOf

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int indexOf (String str, 
                int fromIndex)
```

<br />

<br />

| Parameters ||
|---|---|
| `str` | `String` <br /> |
| `fromIndex` | `int` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                char[] str)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `str` | `char` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                float f)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `f` | `float` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int dstOffset, 
                CharSequence s)
```

<br />

<br />

| Parameters ||
|---|---|
| `dstOffset` | `int` <br /> |
| `s` | `CharSequence` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                char c)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `c` | `char` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                long l)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `l` | `long` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int index, 
                char[] str, 
                int offset, 
                int len)
```

<br />

<br />

| Parameters ||
|---|---|
| `index` | `int` <br /> |
| `str` | `char` <br /> |
| `offset` | `int` <br /> |
| `len` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                int i)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `i` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                String str)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `str` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                double d)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `d` | `double` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int dstOffset, 
                CharSequence s, 
                int start, 
                int end)
```

<br />

<br />

| Parameters ||
|---|---|
| `dstOffset` | `int` <br /> |
| `s` | `CharSequence` <br /> |
| `start` | `int` <br /> |
| `end` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                boolean b)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `b` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### insert

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder insert (int offset, 
                Object obj)
```

<br />

<br />

| Parameters ||
|---|---|
| `offset` | `int` <br /> |
| `obj` | `Object` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### lastIndexOf

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int lastIndexOf (String str, 
                int fromIndex)
```

<br />

<br />

| Parameters ||
|---|---|
| `str` | `String` <br /> |
| `fromIndex` | `int` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### lastIndexOf

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int lastIndexOf (String str)
```

<br />

<br />

| Parameters ||
|---|---|
| `str` | `String` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### length

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int length ()
```

Returns the length (character count).

<br />

| Returns ||
|---|---|
| `int` | the length of the sequence of characters currently represented by this object <br /> |

### offsetByCodePoints

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int offsetByCodePoints (int index, 
                int codePointOffset)
```

Returns the index within this sequence that is offset from the
given `index` by `codePointOffset` code
points. Unpaired surrogates within the text range given by
`index` and `codePointOffset` count as
one code point each.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index to be offset <br /> |
| `codePointOffset` | `int`: the offset in code points <br /> |

| Returns ||
|---|---|
| `int` | the index within this sequence <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `index` is negative or larger then the length of this sequence, or if `codePointOffset` is positive and the subsequence starting with `index` has fewer than `codePointOffset` code points, or if `codePointOffset` is negative and the subsequence before `index` has fewer than the absolute value of `codePointOffset` code points. |

### repeat

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder repeat (int codePoint, 
                int count)
```

<br />

<br />

| Parameters ||
|---|---|
| `codePoint` | `int` <br /> |
| `count` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` |   |

### repeat

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder repeat (CharSequence cs, 
                int count)
```

<br />

<br />

| Parameters ||
|---|---|
| `cs` | `CharSequence` <br /> |
| `count` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` |   |

### replace

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder replace (int start, 
                int end, 
                String str)
```

<br />

<br />

| Parameters ||
|---|---|
| `start` | `int` <br /> |
| `end` | `int` <br /> |
| `str` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` |   |

### reverse

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuilder reverse ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder` | <br /> |

### setCharAt

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setCharAt (int index, 
                char ch)
```

The character at the specified index is set to `ch`. This
sequence is altered to represent a new character sequence that is
identical to the old character sequence, except that it contains the
character `ch` at position `index`.


The index argument must be greater than or equal to
`0`, and less than the length of this sequence.

<br />

| Parameters ||
|---|---|
| `index` | `int`: the index of the character to modify. <br /> |
| `ch` | `char`: the new character. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `index` is negative or greater than or equal to `length()`. |

### setLength

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setLength (int newLength)
```

Sets the length of the character sequence.
The sequence is changed to a new character sequence
whose length is specified by the argument. For every nonnegative
index *k* less than `newLength`, the character at
index *k* in the new character sequence is the same as the
character at index *k* in the old sequence if *k* is less
than the length of the old character sequence; otherwise, it is the
null character `'\u0000'`.

In other words, if the `newLength` argument is less than
the current length, the length is changed to the specified length.


If the `newLength` argument is greater than or equal
to the current length, sufficient null characters
(`'\u0000'`) are appended so that
length becomes the `newLength` argument.


The `newLength` argument must be greater than or equal
to `0`.

<br />

| Parameters ||
|---|---|
| `newLength` | `int`: the new length <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if the `newLength` argument is negative. |

### subSequence

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public CharSequence subSequence (int start, 
                int end)
```

Returns a new character sequence that is a subsequence of this sequence.

An invocation of this method of the form

    sb.subSequence(begin,&nbsp;end)

behaves in exactly the same way as the invocation

    sb.substring(begin,&nbsp;end)

This method is provided so that this class can implement the `https://developer.android.com/reference/java/lang/CharSequence` interface.

<br />

<br />

| Parameters ||
|---|---|
| `start` | `int`: the start index, inclusive. <br /> |
| `end` | `int`: the end index, exclusive. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | the specified subsequence. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `start` or `end` are negative, if `end` is greater than `length()`, or if `start` is greater than `end` |

### substring

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String substring (int start, 
                int end)
```

Returns a new `String` that contains a subsequence of
characters currently contained in this sequence. The
substring begins at the specified `start` and
extends to the character at index `end - 1`.

<br />

| Parameters ||
|---|---|
| `start` | `int`: The beginning index, inclusive. <br /> |
| `end` | `int`: The ending index, exclusive. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | The new string. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` | if `start` or `end` are negative or greater than `length()`, or `start` is greater than `end`. |

### substring

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String substring (int start)
```

Returns a new `String` that contains a subsequence of
characters currently contained in this character sequence. The
substring begins at the specified index and extends to the end of
this sequence.

<br />

| Parameters ||
|---|---|
| `start` | `int`: The beginning index, inclusive. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | The new string. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringIndexOutOfBoundsException` | if `start` is less than zero, or greater than the length of this object. |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### trimToSize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void trimToSize ()
```

Attempts to reduce storage used for the character sequence.
If the buffer is larger than necessary to hold its current sequence of
characters, then it may be resized to become more space efficient.
Calling this method may, but is not required to, affect the value
returned by a subsequent call to the `https://developer.android.com/reference/java/lang/StringBuilder#capacity()` method.

<br />