Stay organized with collections
Save and categorize content based on your preferences.
PrimitiveIterator.OfLong
public
static
interface
PrimitiveIterator.OfLong
implements
PrimitiveIterator<Long, LongConsumer>
java.util.PrimitiveIterator.OfLong
|
An Iterator specialized for long
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
Long
|
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 (LongConsumer action)
Implementation Requirements:
Parameters |
action |
LongConsumer |
forEachRemaining
public void forEachRemaining (Consumer<? super Long> action)
Implementation Requirements:
Parameters |
action |
Consumer |
next
public Long next ()
Returns the next element in the iteration.
Implementation Requirements:
- The default implementation boxes the result of calling
nextLong()
, and returns that boxed result.
Returns |
Long |
the next element in the iteration |
nextLong
public abstract long nextLong ()
Returns the next long
element in the iteration.
Returns |
long |
the next long 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.
[[["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 2025-02-10 UTC."],[],[],null,["# PrimitiveIterator.OfLong\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nPrimitiveIterator.OfLong\n========================\n\n\n`\npublic\nstatic\n\n\ninterface\nPrimitiveIterator.OfLong\n`\n\n\n`\n\n\nimplements\n\n`[PrimitiveIterator](/reference/java/util/PrimitiveIterator)`\u003c`[Long](/reference/java/lang/Long)`, `[LongConsumer](/reference/java/util/function/LongConsumer)`\u003e\n\n\n`\n\n|------------------------------------|\n| java.util.PrimitiveIterator.OfLong |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAn Iterator specialized for `long` values.\n\nSummary\n-------\n\n| ### Public methods ||\n|----------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` default void` | ` `[forEachRemaining](/reference/java/util/PrimitiveIterator.OfLong#forEachRemaining(java.util.function.LongConsumer))`(`[LongConsumer](/reference/java/util/function/LongConsumer)` action) ` |\n| ` default void` | ` `[forEachRemaining](/reference/java/util/PrimitiveIterator.OfLong#forEachRemaining(java.util.function.Consumer\u003c?%20super%20java.lang.Long\u003e))`(`[Consumer](/reference/java/util/function/Consumer)`\u003c? super `[Long](/reference/java/lang/Long)`\u003e action) ` |\n| ` default `[Long](/reference/java/lang/Long) | ` `[next](/reference/java/util/PrimitiveIterator.OfLong#next())`() ` Returns the next element in the iteration. |\n| ` abstract long` | ` `[nextLong](/reference/java/util/PrimitiveIterator.OfLong#nextLong())`() ` Returns the next `long` 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))`(`[LongConsumer](/reference/java/util/function/LongConsumer)` 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 `[Long](/reference/java/lang/Long) | ` `[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 (LongConsumer 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(nextLong());\n \n| Parameters ||\n|----------|-----------------------|\n| `action` | `LongConsumer` \u003cbr /\u003e |\n\n### forEachRemaining\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void forEachRemaining (Consumer\u003c? super Long\u003e action)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Implementation Requirements:\n\n- If the action is an instance of `LongConsumer` then it is cast to `LongConsumer` and passed to [PrimitiveIterator.forEachRemaining(T_CONS)](/reference/java/util/PrimitiveIterator#forEachRemaining(T_CONS)); otherwise the action is adapted to an instance of `LongConsumer`, by boxing the argument of `LongConsumer`, 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### next\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic Long 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 [nextLong()](/reference/java/util/PrimitiveIterator.OfLong#nextLong()), and returns that boxed result.\n\n| Returns ||\n|-----------------------------------|------------------------------------------|\n| [Long](/reference/java/lang/Long) | the next element in the iteration \u003cbr /\u003e |\n\n### nextLong\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract long nextLong ()\n```\n\nReturns the next `long` element in the iteration.\n\n\u003cbr /\u003e\n\n| Returns ||\n|--------|-------------------------------------------------|\n| `long` | the next `long` element in the iteration \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------------------------------|---------------------------------------|\n| [NoSuchElementException](/reference/java/util/NoSuchElementException) | if the iteration has no more elements |"]]