Iterator.forEachRemaining semantics (original) (raw)
Arne Siegel v.a.ammodytes at googlemail.com
Sun Apr 21 09:41:22 PDT 2013
- Previous message: hg: lambda/lambda/jdk: doc updates from Alan's review
- Next message: Iterator.forEachRemaining semantics
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
the apidoc comment of Iterator.forEachRemaining says:
/**
* 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.
*
* @implSpec
* <p>The default implementation behaves as if:
* <pre>{@code
* while (hasNext())
* action.accept(next());
* }</pre>
From this it can be deduced that the following can be true for any implementation:
iterator.forEachRemaining(x -> null).hasNext() == false
What about implementations that don't satisfy this condition? Can they be considered correct?
Regards Arne Siegel
- Previous message: hg: lambda/lambda/jdk: doc updates from Alan's review
- Next message: Iterator.forEachRemaining semantics
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]