# PrimitiveIterator.OfInt

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/java/util/PrimitiveIterator.OfInt#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/PrimitiveIterator.OfInt#inhmethods)  

# PrimitiveIterator.OfInt

`
public
static


interface
PrimitiveIterator.OfInt
`  
`


implements

`[PrimitiveIterator](https://developer.android.com/reference/java/util/PrimitiveIterator)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`, `[IntConsumer](https://developer.android.com/reference/java/util/function/IntConsumer)`>


`

|-----------------------------------|
| java.util.PrimitiveIterator.OfInt |

<br />

*** ** * ** ***

An Iterator specialized for`int`values.

## Summary

|                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                 ||
|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` default void`                                                                 | ` `[forEachRemaining](https://developer.android.com/reference/java/util/PrimitiveIterator.OfInt#forEachRemaining(java.util.function.Consumer<?%20super%20java.lang.Integer>))`(`[Consumer](https://developer.android.com/reference/java/util/function/Consumer)`<? super `[Integer](https://developer.android.com/reference/java/lang/Integer)`> action) ` <br /> |
| ` default void`                                                                 | ` `[forEachRemaining](https://developer.android.com/reference/java/util/PrimitiveIterator.OfInt#forEachRemaining(java.util.function.IntConsumer))`(`[IntConsumer](https://developer.android.com/reference/java/util/function/IntConsumer)` action) ` <br />                                                                                                       |
| ` default `[Integer](https://developer.android.com/reference/java/lang/Integer) | ` `[next](https://developer.android.com/reference/java/util/PrimitiveIterator.OfInt#next())`() ` Returns the next element in the iteration.                                                                                                                                                                                                                       |
| ` abstract int`                                                                 | ` `[nextInt](https://developer.android.com/reference/java/util/PrimitiveIterator.OfInt#nextInt())`() ` Returns the next`int`element in the iteration.                                                                                                                                                                                                             |

| ### Inherited methods |
|-----------------------|---|
| From interface` `[java.util.PrimitiveIterator](https://developer.android.com/reference/java/util/PrimitiveIterator)` ` |------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[forEachRemaining](https://developer.android.com/reference/java/util/PrimitiveIterator#forEachRemaining(T_CONS))`(`[IntConsumer](https://developer.android.com/reference/java/util/function/IntConsumer)` action) ` Performs the given action for each remaining element until all elements have been processed or the action throws an exception. | ||
| From interface` `[java.util.Iterator](https://developer.android.com/reference/java/util/Iterator)` ` |----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default void`                                                                  | ` `[forEachRemaining](https://developer.android.com/reference/java/util/Iterator#forEachRemaining(java.util.function.Consumer<?%20super%20E>))`(`[Consumer](https://developer.android.com/reference/java/util/function/Consumer)`<? 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://developer.android.com/reference/java/util/Iterator#hasNext())`() ` Returns`true`if the iteration has more elements.                                                                                                                                                                                                                                              | | ` abstract `[Integer](https://developer.android.com/reference/java/lang/Integer) | ` `[next](https://developer.android.com/reference/java/util/Iterator#next())`() ` Returns the next element in the iteration.                                                                                                                                                                                                                                                          | | ` default void`                                                                  | ` `[remove](https://developer.android.com/reference/java/util/Iterator#remove())`() ` Removes from the underlying collection the last element returned by this iterator (optional operation).                                                                                                                                                                                         | ||

## Public methods

### forEachRemaining

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

```
public void forEachRemaining (Consumer<? super Integer> action)
```

<br />

<br />

##### Implementation Requirements:

- If the action is an instance of`IntConsumer`then it is cast to`IntConsumer`and passed to[PrimitiveIterator.forEachRemaining(T_CONS)](https://developer.android.com/reference/java/util/PrimitiveIterator#forEachRemaining(T_CONS)); otherwise the action is adapted to an instance of`IntConsumer`, by boxing the argument of`IntConsumer`, and then passed to[PrimitiveIterator.forEachRemaining(T_CONS)](https://developer.android.com/reference/java/util/PrimitiveIterator#forEachRemaining(T_CONS)).

|         Parameters          ||
|----------|-------------------|
| `action` | `Consumer` <br /> |

### forEachRemaining

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

```
public void forEachRemaining (IntConsumer action)
```

<br />

<br />

##### Implementation Requirements:

- The default implementation behaves as if:

      while (hasNext())
               action.accept(nextInt());
       
|           Parameters           ||
|----------|----------------------|
| `action` | `IntConsumer` <br /> |

### next

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

```
public Integer next ()
```

Returns the next element in the iteration.

<br />

##### Implementation Requirements:

- The default implementation boxes the result of calling[nextInt()](https://developer.android.com/reference/java/util/PrimitiveIterator.OfInt#nextInt()), and returns that boxed result.

|                                                    Returns                                                     ||
|----------------------------------------------------------------------|------------------------------------------|
| [Integer](https://developer.android.com/reference/java/lang/Integer) | the next element in the iteration <br /> |

### nextInt

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

```
public abstract int nextInt ()
```

Returns the next`int`element in the iteration.

<br />

|                       Returns                       ||
|-------|----------------------------------------------|
| `int` | the next`int`element in the iteration <br /> |

|                                                                  Throws                                                                   ||
|----------------------------------------------------------------------------------------------------|---------------------------------------|
| [NoSuchElementException](https://developer.android.com/reference/java/util/NoSuchElementException) | if the iteration has no more elements |