T
- the type of elements returned by the iteratorpublic interface Iterable<T>
for
statement (sometimes called the "for-each loop" statement).Modifier and Type | Method | Description |
---|---|---|
default void |
forEach(java.util.function.Consumer<? super T> action) |
Performs the given action for each element of the
Iterable
until all elements have been processed or the action throws an
exception. |
java.util.Iterator<T> |
iterator() |
Returns an iterator over elements of type
T . |
default java.util.Spliterator<T> |
spliterator() |
Creates a
Spliterator over the elements described by this
Iterable . |
java.util.Iterator<T> iterator()
T
.default void forEach(java.util.function.Consumer<? super T> action)
Iterable
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 this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy.
action
- The action to be performed for each elementNullPointerException
- if the specified action is nulldefault java.util.Spliterator<T> spliterator()
Spliterator
over the elements described by this
Iterable
.Spliterator
over the elements described by this
Iterable
.