# PrimitiveIterator.OfLong

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.OfLong#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/PrimitiveIterator.OfLong#inhmethods)  

# PrimitiveIterator.OfLong

`
public
static


interface
PrimitiveIterator.OfLong
`  
`


implements

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


`

|------------------------------------|
| java.util.PrimitiveIterator.OfLong |

<br />

*** ** * ** ***

An Iterator specialized for`long`values.

## Summary

|                                                                                                                                                                                                          ### Public methods                                                                                                                                                                                                          ||
|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` default void`                                                           | ` `[forEachRemaining](https://developer.android.com/reference/java/util/PrimitiveIterator.OfLong#forEachRemaining(java.util.function.LongConsumer))`(`[LongConsumer](https://developer.android.com/reference/java/util/function/LongConsumer)` action) ` <br />                                                                                           |
| ` default void`                                                           | ` `[forEachRemaining](https://developer.android.com/reference/java/util/PrimitiveIterator.OfLong#forEachRemaining(java.util.function.Consumer<?%20super%20java.lang.Long>))`(`[Consumer](https://developer.android.com/reference/java/util/function/Consumer)`<? super `[Long](https://developer.android.com/reference/java/lang/Long)`> action) ` <br /> |
| ` default `[Long](https://developer.android.com/reference/java/lang/Long) | ` `[next](https://developer.android.com/reference/java/util/PrimitiveIterator.OfLong#next())`() ` Returns the next element in the iteration.                                                                                                                                                                                                              |
| ` abstract long`                                                          | ` `[nextLong](https://developer.android.com/reference/java/util/PrimitiveIterator.OfLong#nextLong())`() ` Returns the next`long`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))`(`[LongConsumer](https://developer.android.com/reference/java/util/function/LongConsumer)` 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 `[Long](https://developer.android.com/reference/java/lang/Long) | ` `[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 (LongConsumer action)
```

<br />

<br />

##### Implementation Requirements:

- The default implementation behaves as if:

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

### forEachRemaining

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

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

<br />

<br />

##### Implementation Requirements:

- If the action is an instance of`LongConsumer`then it is cast to`LongConsumer`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`LongConsumer`, by boxing the argument of`LongConsumer`, and then passed to[PrimitiveIterator.forEachRemaining(T_CONS)](https://developer.android.com/reference/java/util/PrimitiveIterator#forEachRemaining(T_CONS)).

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

### next

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

```
public Long next ()
```

Returns the next element in the iteration.

<br />

##### Implementation Requirements:

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

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

### nextLong

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

```
public abstract long nextLong ()
```

Returns the next`long`element in the iteration.

<br />

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

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