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

# Spliterator.OfPrimitive

` public static interface Spliterator.OfPrimitive `   
` implements https://developer.android.com/reference/java/util/Spliterator<T> `

|---|
| java.util.Spliterator.OfPrimitive\<T, T_CONS, T_SPLITR extends [java.util.Spliterator.OfPrimitive](https://developer.android.com/reference/java/util/Spliterator.OfPrimitive)\<T, T_CONS, T_SPLITR\>\> |

Known indirect subclasses [Spliterator.OfDouble](https://developer.android.com/reference/java/util/Spliterator.OfDouble), [Spliterator.OfInt](https://developer.android.com/reference/java/util/Spliterator.OfInt), [Spliterator.OfLong](https://developer.android.com/reference/java/util/Spliterator.OfLong), [Spliterators.AbstractDoubleSpliterator](https://developer.android.com/reference/java/util/Spliterators.AbstractDoubleSpliterator), [Spliterators.AbstractIntSpliterator](https://developer.android.com/reference/java/util/Spliterators.AbstractIntSpliterator), [Spliterators.AbstractLongSpliterator](https://developer.android.com/reference/java/util/Spliterators.AbstractLongSpliterator) [Spliterator.OfDouble](https://developer.android.com/reference/java/util/Spliterator.OfDouble) A Spliterator specialized for `double` values. [Spliterator.OfInt](https://developer.android.com/reference/java/util/Spliterator.OfInt) A Spliterator specialized for `int` values. [Spliterator.OfLong](https://developer.android.com/reference/java/util/Spliterator.OfLong) A Spliterator specialized for `long` values. [Spliterators.AbstractDoubleSpliterator](https://developer.android.com/reference/java/util/Spliterators.AbstractDoubleSpliterator) An abstract `Spliterator.OfDouble` that implements `trySplit` to permit limited parallelism. [Spliterators.AbstractIntSpliterator](https://developer.android.com/reference/java/util/Spliterators.AbstractIntSpliterator) An abstract `Spliterator.OfInt` that implements `trySplit` to permit limited parallelism. [Spliterators.AbstractLongSpliterator](https://developer.android.com/reference/java/util/Spliterators.AbstractLongSpliterator) An abstract `Spliterator.OfLong` that implements `trySplit` to permit limited parallelism.   

*** ** * ** ***

A Spliterator specialized for primitive values.
**See also:**

- `https://developer.android.com/reference/java/util/Spliterator.OfInt`
- `https://developer.android.com/reference/java/util/Spliterator.OfLong`
- `https://developer.android.com/reference/java/util/Spliterator.OfDouble`

## Summary

### Inherited constants

From interface `https://developer.android.com/reference/java/util/Spliterator` `int` `https://developer.android.com/reference/java/util/Spliterator#CONCURRENT`

Characteristic value signifying that the element source may be safely concurrently modified (allowing additions, replacements, and/or removals) by multiple threads without external synchronization.
`int` `https://developer.android.com/reference/java/util/Spliterator#DISTINCT`

Characteristic value signifying that, for each pair of encountered elements `x, y`, `!x.equals(y)`.
`int` `https://developer.android.com/reference/java/util/Spliterator#IMMUTABLE`

Characteristic value signifying that the element source cannot be structurally modified; that is, elements cannot be added, replaced, or removed, so such changes cannot occur during traversal.
`int` `https://developer.android.com/reference/java/util/Spliterator#NONNULL`

Characteristic value signifying that the source guarantees that encountered elements will not be `null`.
`int` `https://developer.android.com/reference/java/util/Spliterator#ORDERED`

Characteristic value signifying that an encounter order is defined for elements.
`int` `https://developer.android.com/reference/java/util/Spliterator#SIZED`

Characteristic value signifying that the value returned from `estimateSize()` prior to traversal or splitting represents a finite size that, in the absence of structural source modification, represents an exact count of the number of elements that would be encountered by a complete traversal.
`int` `https://developer.android.com/reference/java/util/Spliterator#SORTED`

Characteristic value signifying that encounter order follows a defined sort order.
`int` `https://developer.android.com/reference/java/util/Spliterator#SUBSIZED`

Characteristic value signifying that all Spliterators resulting from `trySplit()` will be both `https://developer.android.com/reference/java/util/Spliterator#SIZED` and `https://developer.android.com/reference/java/util/Spliterator#SUBSIZED`.

| ### Public methods ||
|---|---|
| ` default void` | ` https://developer.android.com/reference/java/util/Spliterator.OfPrimitive#forEachRemaining(T_CONS)(T_CONS action) ` Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception. |
| ` abstract boolean` | ` https://developer.android.com/reference/java/util/Spliterator.OfPrimitive#tryAdvance(T_CONS)(T_CONS action) ` If a remaining element exists, performs the given action on it, returning `true`; else returns `false`. |
| ` abstract T_SPLITR` | ` https://developer.android.com/reference/java/util/Spliterator.OfPrimitive#trySplit()() ` If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator. |

### Inherited methods

From interface ` https://developer.android.com/reference/java/util/Spliterator ` ` abstract int` ` https://developer.android.com/reference/java/util/Spliterator#characteristics()() `

Returns a set of characteristics of this Spliterator and its elements.
` abstract long` ` https://developer.android.com/reference/java/util/Spliterator#estimateSize()() `

Returns an estimate of the number of elements that would be encountered by a `https://developer.android.com/reference/java/util/Spliterator#forEachRemaining(java.util.function.Consumer<?%20super%20T>)` traversal, or returns `https://developer.android.com/reference/java/lang/Long#MAX_VALUE` if infinite, unknown, or too expensive to compute.
` default void` ` https://developer.android.com/reference/java/util/Spliterator#forEachRemaining(java.util.function.Consumer<?%20super%20T>)(https://developer.android.com/reference/java/util/function/Consumer<? super T> action) `

Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.
` default https://developer.android.com/reference/java/util/Comparator<? super T>` ` https://developer.android.com/reference/java/util/Spliterator#getComparator()() `

If this Spliterator's source is `https://developer.android.com/reference/java/util/Spliterator#SORTED` by a `https://developer.android.com/reference/java/util/Comparator`, returns that `Comparator`.
` default long` ` https://developer.android.com/reference/java/util/Spliterator#getExactSizeIfKnown()() `

Convenience method that returns `https://developer.android.com/reference/java/util/Spliterator#estimateSize()` if this Spliterator is `https://developer.android.com/reference/java/util/Spliterator#SIZED`, else `-1`.
` default boolean` ` https://developer.android.com/reference/java/util/Spliterator#hasCharacteristics(int)(int characteristics) `

Returns `true` if this Spliterator's `https://developer.android.com/reference/java/util/Spliterator#characteristics()` contain all of the given characteristics.
` abstract boolean` ` https://developer.android.com/reference/java/util/Spliterator#tryAdvance(java.util.function.Consumer<?%20super%20T>)(https://developer.android.com/reference/java/util/function/Consumer<? super T> action) `

If a remaining element exists: performs the given action on it, returning `true`; else returns `false`.
` abstract https://developer.android.com/reference/java/util/Spliterator<T>` ` https://developer.android.com/reference/java/util/Spliterator#trySplit()() `

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.

## Public methods

### forEachRemaining

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

```
public void forEachRemaining (T_CONS action)
```

Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception. If this Spliterator is `https://developer.android.com/reference/java/util/Spliterator#ORDERED`, actions are performed in encounter order. Exceptions thrown by the action are relayed to the caller.

Subsequent behavior of a spliterator is unspecified if the action throws an exception.

<br />

##### Implementation Requirements:

- The default implementation repeatedly invokes `https://developer.android.com/reference/java/util/Spliterator.OfPrimitive#tryAdvance(T_CONS)` until it returns `false`. It should be overridden whenever possible.

| Parameters ||
|---|---|
| `action` | `T_CONS`: The action <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the specified action is null |

### tryAdvance

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

```
public abstract boolean tryAdvance (T_CONS action)
```

If a remaining element exists, performs the given action on it, returning `true`; else returns `false`. If this Spliterator is `https://developer.android.com/reference/java/util/Spliterator#ORDERED` the action is performed on the next element in encounter order. Exceptions thrown by the action are relayed to the caller.

Subsequent behavior of a spliterator is unspecified if the action throws an exception.

<br />

| Parameters ||
|---|---|
| `action` | `T_CONS`: The action <br /> |

| Returns ||
|---|---|
| `boolean` | `false` if no remaining elements existed upon entry to this method, else `true`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the specified action is null |

### trySplit

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

```
public abstract T_SPLITR trySplit ()
```

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.

If this Spliterator is `https://developer.android.com/reference/java/util/Spliterator#ORDERED`, the returned Spliterator must cover a strict prefix of the elements.

Unless this Spliterator covers an infinite number of elements, repeated calls to `trySplit()` must eventually return `null`. Upon non-null return:

- the value reported for `estimateSize()` before splitting, must, after splitting, be greater than or equal to `estimateSize()` for this and the returned Spliterator; and
- if this Spliterator is `SUBSIZED`, then `estimateSize()` for this spliterator before splitting must be equal to the sum of `estimateSize()` for this and the returned Spliterator after splitting.

This method may return `null` for any reason, including emptiness, inability to split after traversal has commenced, data structure constraints, and efficiency considerations.

<br />

| Returns ||
|---|---|
| `T_SPLITR` | a `Spliterator` covering some portion of the elements, or `null` if this spliterator cannot be split <br /> |