Stay organized with collections
Save and categorize content based on your preferences.
PrimitiveIterator.OfInt
public
static
interface
PrimitiveIterator.OfInt
implements
PrimitiveIterator<Integer, IntConsumer>
java.util.PrimitiveIterator.OfInt
|
An Iterator specialized for int
values.
Summary
Inherited methods |
|
From interface
java.util.Iterator
default
void
|
forEachRemaining(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()
Returns true if the iteration has more elements.
|
abstract
Integer
|
next()
Returns the next element in the iteration.
|
default
void
|
remove()
Removes from the underlying collection the last element returned
by this iterator (optional operation).
|
|
Public methods
forEachRemaining
public void forEachRemaining (Consumer<? super Integer> action)
Implementation Requirements:
Parameters |
action |
Consumer |
forEachRemaining
public void forEachRemaining (IntConsumer action)
Implementation Requirements:
Parameters |
action |
IntConsumer |
next
public Integer next ()
Returns the next element in the iteration.
Implementation Requirements:
- The default implementation boxes the result of calling
nextInt()
, and returns that boxed result.
Returns |
Integer |
the next element in the iteration |
nextInt
public abstract int nextInt ()
Returns the next int
element in the iteration.
Returns |
int |
the next int element in the iteration |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# PrimitiveIterator.OfInt\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nPrimitiveIterator.OfInt\n=======================\n\n\n`\npublic\nstatic\n\n\ninterface\nPrimitiveIterator.OfInt\n`\n\n\n`\n\n\nimplements\n\n`[PrimitiveIterator](/reference/java/util/PrimitiveIterator)`\u003c`[Integer](/reference/java/lang/Integer)`, `[IntConsumer](/reference/java/util/function/IntConsumer)`\u003e\n\n\n`\n\n|-----------------------------------|\n| java.util.PrimitiveIterator.OfInt |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAn Iterator specialized for `int` values.\n\nSummary\n-------\n\n| ### Public methods ||\n|----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` default void` | ` `[forEachRemaining](/reference/java/util/PrimitiveIterator.OfInt#forEachRemaining(java.util.function.Consumer\u003c?%20super%20java.lang.Integer\u003e))`(`[Consumer](/reference/java/util/function/Consumer)`\u003c? super `[Integer](/reference/java/lang/Integer)`\u003e action) ` |\n| ` default void` | ` `[forEachRemaining](/reference/java/util/PrimitiveIterator.OfInt#forEachRemaining(java.util.function.IntConsumer))`(`[IntConsumer](/reference/java/util/function/IntConsumer)` action) ` |\n| ` default `[Integer](/reference/java/lang/Integer) | ` `[next](/reference/java/util/PrimitiveIterator.OfInt#next())`() ` Returns the next element in the iteration. |\n| ` abstract int` | ` `[nextInt](/reference/java/util/PrimitiveIterator.OfInt#nextInt())`() ` Returns the next `int` element in the iteration. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.util.PrimitiveIterator](/reference/java/util/PrimitiveIterator)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[forEachRemaining](/reference/java/util/PrimitiveIterator#forEachRemaining(T_CONS))`(`[IntConsumer](/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. | ||\n| From interface ` `[java.util.Iterator](/reference/java/util/Iterator)` ` |-----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default void` | ` `[forEachRemaining](/reference/java/util/Iterator#forEachRemaining(java.util.function.Consumer\u003c?%20super%20E\u003e))`(`[Consumer](/reference/java/util/function/Consumer)`\u003c? super E\u003e action) ` Performs the given action for each remaining element until all elements have been processed or the action throws an exception. | | ` abstract boolean` | ` `[hasNext](/reference/java/util/Iterator#hasNext())`() ` Returns `true` if the iteration has more elements. | | ` abstract `[Integer](/reference/java/lang/Integer) | ` `[next](/reference/java/util/Iterator#next())`() ` Returns the next element in the iteration. | | ` default void` | ` `[remove](/reference/java/util/Iterator#remove())`() ` Removes from the underlying collection the last element returned by this iterator (optional operation). | ||\n\nPublic methods\n--------------\n\n### forEachRemaining\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void forEachRemaining (Consumer\u003c? super Integer\u003e action)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Implementation Requirements:\n\n- If the action is an instance of `IntConsumer` then it is cast to `IntConsumer` and passed to [PrimitiveIterator.forEachRemaining(T_CONS)](/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)](/reference/java/util/PrimitiveIterator#forEachRemaining(T_CONS)).\n\n| Parameters ||\n|----------|-------------------|\n| `action` | `Consumer` \u003cbr /\u003e |\n\n### forEachRemaining\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void forEachRemaining (IntConsumer action)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Implementation Requirements:\n\n- The default implementation behaves as if:\n\n while (hasNext())\n action.accept(nextInt());\n \n| Parameters ||\n|----------|----------------------|\n| `action` | `IntConsumer` \u003cbr /\u003e |\n\n### next\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic Integer next ()\n```\n\nReturns the next element in the iteration.\n\n\u003cbr /\u003e\n\n##### Implementation Requirements:\n\n- The default implementation boxes the result of calling [nextInt()](/reference/java/util/PrimitiveIterator.OfInt#nextInt()), and returns that boxed result.\n\n| Returns ||\n|-----------------------------------------|------------------------------------------|\n| [Integer](/reference/java/lang/Integer) | the next element in the iteration \u003cbr /\u003e |\n\n### nextInt\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract int nextInt ()\n```\n\nReturns the next `int` element in the iteration.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|------------------------------------------------|\n| `int` | the next `int` element in the iteration \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------------------------------|---------------------------------------|\n| [NoSuchElementException](/reference/java/util/NoSuchElementException) | if the iteration has no more elements |"]]