Skip to content

Most visited

Recently visited

navigation

PrimitiveIterator

public interface PrimitiveIterator
implements Iterator<T>

java.util.PrimitiveIterator<T, T_CONS>
Known Indirect Subclasses


A base type for primitive specializations of Iterator. Specialized subtypes are provided for int, long, and double values.

The specialized subtype default implementations of next() and forEachRemaining(java.util.function.Consumer) 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, nextInt() and forEachRemaining(java.util.function.IntConsumer) should be used in preference to next() and forEachRemaining(java.util.function.Consumer).

Iteration of primitive values using boxing-based methods next() and forEachRemaining(), does not affect the order in which the values, transformed to boxed values, are encountered.

Summary

Nested classes

interface PrimitiveIterator.OfDouble

An Iterator specialized for double values. 

interface PrimitiveIterator.OfInt

An Iterator specialized for int values. 

interface PrimitiveIterator.OfLong

An Iterator specialized for long values. 

Public methods

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.

Inherited methods

From interface java.util.Iterator

Public methods

forEachRemaining

added in API level 24
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 T_CONS: The action to be performed for each element

Throws
NullPointerException if the specified action is null
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)