# StringCharacterIterator

public final class **StringCharacterIterator** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [CharacterIterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html) `StringCharacterIterator` implements the
`CharacterIterator` protocol for a `String`.
The `StringCharacterIterator` class iterates over the
entire `String`.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html`

### Inherited Constant Summary

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

|---|---|---|
| char | [DONE](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#DONE) | Constant that is returned when the iterator has reached either the end or the beginning of the text. |

### Public Constructor Summary

|---|---|
|   | [StringCharacterIterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#StringCharacterIterator(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) text) Constructs an iterator with an initial index of 0. |
|   | [StringCharacterIterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#StringCharacterIterator(java.lang.String,%20int))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) text, int pos) Constructs an iterator with the specified initial index. |
|   | [StringCharacterIterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#StringCharacterIterator(java.lang.String,%20int,%20int,%20int))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) text, int begin, int end, int pos) Constructs an iterator over the given range of the given string, with the index set at the specified position. |

### Public Method Summary

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#clone())() Creates a copy of this iterator. |
| char | [current](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#current())() Implements CharacterIterator.current() for String. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares the equality of two StringCharacterIterator objects. |
| char | [first](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#first())() Implements CharacterIterator.first() for String. |
| int | [getBeginIndex](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#getBeginIndex())() Implements CharacterIterator.getBeginIndex() for String. |
| int | [getEndIndex](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#getEndIndex())() Implements CharacterIterator.getEndIndex() for String. |
| int | [getIndex](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#getIndex())() Implements CharacterIterator.getIndex() for String. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#hashCode())() Computes a hashcode for this iterator. |
| char | [last](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#last())() Implements CharacterIterator.last() for String. |
| char | [next](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#next())() Implements CharacterIterator.next() for String. |
| char | [previous](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#previous())() Implements CharacterIterator.previous() for String. |
| char | [setIndex](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#setIndex(int))(int p) Implements CharacterIterator.setIndex() for String. |
| void | [setText](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/StringCharacterIterator.html#setText(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) text) Reset this iterator to point to a new string. |

### 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.text.CharacterIterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html)

|---|---|
| abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#clone())() Create a copy of this iterator |
| abstract char | [current](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#current())() Gets the character at the current position (as returned by getIndex()). |
| abstract char | [first](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#first())() Sets the position to getBeginIndex() and returns the character at that position. |
| abstract int | [getBeginIndex](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#getBeginIndex())() Returns the start index of the text. |
| abstract int | [getEndIndex](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#getEndIndex())() Returns the end index of the text. |
| abstract int | [getIndex](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#getIndex())() Returns the current index. |
| abstract char | [last](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#last())() Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) and returns the character at that position. |
| abstract char | [next](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#next())() Increments the iterator's index by one and returns the character at the new index. |
| abstract char | [previous](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#previous())() Decrements the iterator's index by one and returns the character at the new index. |
| abstract char | [setIndex](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#setIndex(int))(int position) Sets the position to the specified position in the text and returns that character. |

## Public Constructors

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

Constructs an iterator with an initial index of 0.

##### Parameters

| text | the `String` to be iterated over |
|---|---|

#### public
**StringCharacterIterator**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) text, int pos)

Constructs an iterator with the specified initial index.

##### Parameters

| text | The String to be iterated over |
| pos | Initial iterator position |
|---|---|

#### public
**StringCharacterIterator**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) text, int begin, int end, int pos)

Constructs an iterator over the given range of the given string, with the
index set at the specified position.

##### Parameters

| text | The String to be iterated over |
| begin | Index of the first character |
| end | Index of the character following the last character |
| pos | Initial iterator position |
|---|---|

## Public Methods

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

Creates a copy of this iterator.

##### Returns

- A copy of this

#### public char
**current**
()

Implements CharacterIterator.current() for String.

##### Returns

- the character at the current position or DONE if the current position is off the end of the text.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#current()`

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

Compares the equality of two StringCharacterIterator objects.

##### Parameters

| obj | the StringCharacterIterator object to be compared with. |
|---|---|

##### Returns

- true if the given obj is the same as this StringCharacterIterator object; false otherwise.

#### public char
**first**
()

Implements CharacterIterator.first() for String.

##### Returns

- the first character in the text, or DONE if the text is empty

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#first()`

#### public int
**getBeginIndex**
()

Implements CharacterIterator.getBeginIndex() for String.

##### Returns

- the index at which the text begins.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#getBeginIndex()`

#### public int
**getEndIndex**
()

Implements CharacterIterator.getEndIndex() for String.

##### Returns

- the index after the last character in the text

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#getEndIndex()`

#### public int
**getIndex**
()

Implements CharacterIterator.getIndex() for String.

##### Returns

- the current index.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#getIndex()`

#### public int
**hashCode**
()

Computes a hashcode for this iterator.

##### Returns

- A hash code

#### public char
**last**
()

Implements CharacterIterator.last() for String.

##### Returns

- the last character in the text, or DONE if the text is empty

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#last()`

#### public char
**next**
()

Implements CharacterIterator.next() for String.

##### Returns

- the character at the new position or DONE if the new position is off the end of the text range.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#next()`

#### public char
**previous**
()

Implements CharacterIterator.previous() for String.

##### Returns

- the character at the new position or DONE if the current position is equal to getBeginIndex().

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#previous()`

#### public char
**setIndex**
(int p)

Implements CharacterIterator.setIndex() for String.

##### Parameters

| p | the position within the text. Valid values range from getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown if an invalid value is supplied. |
|---|---|

##### Returns

- the character at the specified position or DONE if the specified position is equal to getEndIndex()

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CharacterIterator.html#setIndex(int)`

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

Reset this iterator to point to a new string. This package-visible
method is used by other java.text classes that want to avoid allocating
new StringCharacterIterator objects every time their setText method
is called.

##### Parameters

| text | The String to be iterated over |
|---|---|