PrimitiveIterator.OfInt (Java SE 9 & JDK 9 ) (original) (raw)
- All Superinterfaces:
[Iterator](../../java/util/Iterator.html "interface in java.util")<[Integer](../../java/lang/Integer.html "class in java.lang")>
,[PrimitiveIterator](../../java/util/PrimitiveIterator.html "interface in java.util")<[Integer](../../java/lang/Integer.html "class in java.lang"),[IntConsumer](../../java/util/function/IntConsumer.html "interface in java.util.function")>
Enclosing interface:
PrimitiveIterator<T,T_CONS>
public static interface PrimitiveIterator.OfInt
extends PrimitiveIterator<Integer,IntConsumer>
An Iterator specialized for int
values.
Since:
1.8
Nested Class Summary
* ### Nested classes/interfaces inherited from interface java.util.[PrimitiveIterator](../../java/util/PrimitiveIterator.html "interface in java.util") `[PrimitiveIterator.OfDouble](../../java/util/PrimitiveIterator.OfDouble.html "interface in java.util"), [PrimitiveIterator.OfInt](../../java/util/PrimitiveIterator.OfInt.html "interface in java.util"), [PrimitiveIterator.OfLong](../../java/util/PrimitiveIterator.OfLong.html "interface in java.util")`
Method Summary
All Methods Instance Methods Abstract Methods Default Methods
Modifier and Type Method Description default void forEachRemaining(Consumer<? super Integer> action) Performs the given action for each remaining element until all elements have been processed or the action throws an exception. default void forEachRemaining(IntConsumer action) Performs the given action for each remaining element until all elements have been processed or the action throws an exception. default Integer next() Returns the next element in the iteration. int nextInt() Returns the next int element in the iteration. * ### Methods inherited from interface java.util.[Iterator](../../java/util/Iterator.html "interface in java.util") `[hasNext](../../java/util/Iterator.html#hasNext--), [remove](../../java/util/Iterator.html#remove--)`
Method Detail
* #### nextInt int nextInt() Returns the next `int` element in the iteration. Returns: the next `int` element in the iteration Throws: `[NoSuchElementException](../../java/util/NoSuchElementException.html "class in java.util")` \- if the iteration has no more elements * #### forEachRemaining default void forEachRemaining([IntConsumer](../../java/util/function/IntConsumer.html "interface in java.util.function") action) Performs the given action for each remaining element until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller. Specified by: `[forEachRemaining](../../java/util/PrimitiveIterator.html#forEachRemaining-T%5FCONS-)` in interface `[PrimitiveIterator](../../java/util/PrimitiveIterator.html "interface in java.util")<[Integer](../../java/lang/Integer.html "class in java.lang"),[IntConsumer](../../java/util/function/IntConsumer.html "interface in java.util.function")>` Implementation Requirements: The default implementation behaves as if: ``` while (hasNext()) action.accept(nextInt()); ``` Parameters: `action` \- The action to be performed for each element Throws: `[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")` \- if the specified action is null * #### next default [Integer](../../java/lang/Integer.html "class in java.lang") next() Returns the next element in the iteration. Specified by: `[next](../../java/util/Iterator.html#next--)` in interface `[Iterator](../../java/util/Iterator.html "interface in java.util")<[Integer](../../java/lang/Integer.html "class in java.lang")>` Implementation Requirements: The default implementation boxes the result of calling[nextInt()](../../java/util/PrimitiveIterator.OfInt.html#nextInt--), and returns that boxed result. Returns: the next element in the iteration * #### forEachRemaining default void forEachRemaining([Consumer](../../java/util/function/Consumer.html "interface in java.util.function")<? super [Integer](../../java/lang/Integer.html "class in java.lang")> action) Performs the given action for each remaining element until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller. The behavior of an iterator is unspecified if the action modifies the collection in any way (even by calling the [remove](../../java/util/Iterator.html#remove--) method or other mutator methods of `Iterator` subtypes), unless an overriding class has specified a concurrent modification policy. Subsequent behavior of an iterator is unspecified if the action throws an exception. Specified by: `[forEachRemaining](../../java/util/Iterator.html#forEachRemaining-java.util.function.Consumer-)` in interface `[Iterator](../../java/util/Iterator.html "interface in java.util")<[Integer](../../java/lang/Integer.html "class in java.lang")>` Implementation Requirements: If the action is an instance of `IntConsumer` then it is cast to `IntConsumer` and passed to [forEachRemaining(java.util.function.IntConsumer)](../../java/util/PrimitiveIterator.OfInt.html#forEachRemaining-java.util.function.IntConsumer-); otherwise the action is adapted to an instance of`IntConsumer`, by boxing the argument of `IntConsumer`, and then passed to [forEachRemaining(java.util.function.IntConsumer)](../../java/util/PrimitiveIterator.OfInt.html#forEachRemaining-java.util.function.IntConsumer-). Parameters: `action` \- The action to be performed for each element
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.