PrimitiveIterator.OfInt
Stay organized with collections
Save and categorize content based on your preferences.
An Iterator specialized for int
values.
Public Method Summary
void
|
|
void
|
forEachRemaining( IntConsumer action)
Performs the given action for each remaining element until all elements
have been processed or the action throws an exception.
|
Integer
|
next()
Returns the next element in the iteration.
|
abstract
int
|
nextInt()
Returns the next int element in the iteration.
|
Inherited Method Summary
From interface
java.util.Iterator
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.
|
void
|
remove()
Removes from the underlying collection the last element returned
by this iterator (optional operation).
|
Public Methods
public
void
forEachRemaining
(IntConsumer 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.
Parameters
action |
The action to be performed for each element |
public
Integer
next
()
Returns the next element in the iteration.
Returns
- the next element in the iteration
public
abstract
int
nextInt
()
Returns the next int
element in the iteration.
Returns
- the next
int
element in the iteration
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["`PrimitiveIterator.OfInt` is an iterator specifically designed for handling `int` values."],["It provides methods like `nextInt()` to directly retrieve the next `int` element and `forEachRemaining()` to process remaining elements."],["This iterator inherits functionalities from `PrimitiveIterator` and `Iterator`, offering methods like `hasNext()`, `next()`, and `remove()`."],["The `forEachRemaining()` method can accept both `Consumer\u003cInteger\u003e` and `IntConsumer` for processing elements."],["If there are no more elements to iterate, calling `nextInt()` will result in a `NoSuchElementException`."]]],["`PrimitiveIterator.OfInt` is a specialized iterator for `int` values. Key actions include `forEachRemaining(IntConsumer action)`, which applies an action to remaining elements, and `nextInt()`, which retrieves the next `int` element. It also inherits `forEachRemaining` and `next()` which acts on consumer and return the next element. `hasNext()` checks for more elements and `remove()` allows for element removal. Errors such as `NullPointerException` and `NoSuchElementException` can be thrown.\n"]]