# PrimitiveIterator

public interface **PrimitiveIterator** implements [Iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html)\<T\>

|---|---|---|
| Known Indirect Subclasses [PrimitiveIterator.OfDouble](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfDouble.html), [PrimitiveIterator.OfInt](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfInt.html), [PrimitiveIterator.OfLong](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfLong.html) |---|---| | [PrimitiveIterator.OfDouble](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfDouble.html) | An Iterator specialized for `double` values. | | [PrimitiveIterator.OfInt](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfInt.html) | An Iterator specialized for `int` values. | | [PrimitiveIterator.OfLong](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfLong.html) | An Iterator specialized for `long` values. | |||

A base type for primitive specializations of `Iterator`. Specialized
subtypes are provided for `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfInt.html`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfLong.html`, and
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfDouble.html` values.

The specialized subtype default implementations of `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#next()`
and `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#forEachRemaining(java.util.function.Consumer<?%20super%20E>)` box
primitive values to instances of their corresponding wrapper class. Such
boxing may offset any advantages gained when using the primitive
specializations. To avoid boxing, the corresponding primitive-based methods
should be used. For example, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfInt.html#nextInt()` and
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfInt.html#forEachRemaining(java.util.function.IntConsumer)`
should be used in preference to `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfInt.html#next()` and
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#forEachRemaining(java.util.function.Consumer<?%20super%20E>)`.

Iteration of primitive values using boxing-based methods
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#next()` and
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#forEachRemaining(java.util.function.Consumer<?%20super%20E>)`,
does not affect the order in which the values, transformed to boxed values,
are encountered.

### Nested Class Summary

|---|---|---|---|
| interface | [PrimitiveIterator.OfDouble](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfDouble.html) || An Iterator specialized for `double` values. |
| interface | [PrimitiveIterator.OfInt](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfInt.html) || An Iterator specialized for `int` values. |
| interface | [PrimitiveIterator.OfLong](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.OfLong.html) || An Iterator specialized for `long` values. |

### Public Method Summary

|---|---|
| abstract void | [forEachRemaining](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PrimitiveIterator.html#forEachRemaining(T_CONS))(T_CONS action) Performs the given action for each remaining element, in the order elements occur when iterating, until all elements have been processed or the action throws an exception. |

### Inherited Method Summary

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

|---|---|
| void | [forEachRemaining](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#forEachRemaining(java.util.function.Consumer<?%20super%20E>))([Consumer](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Consumer.html)\<? super E\> action) Performs the given action for each remaining element until all elements have been processed or the action throws an exception. |
| abstract boolean | [hasNext](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#hasNext())() Returns `true` if the iteration has more elements. |
| abstract T | [next](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#next())() Returns the next element in the iteration. |
| void | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html#remove())() Removes from the underlying collection the last element returned by this iterator (optional operation). |

## Public Methods

#### public abstract void
**forEachRemaining**
(T_CONS action)

Performs the given action for each remaining element, in the order
elements occur when iterating, until all elements have been processed
or the action throws an exception. Errors or runtime exceptions
thrown by the action are relayed to the caller.

##### Parameters

| action | The action to be performed for each element |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the specified action is null |
|---|---|