, SingletonSet<E>, , singleton Collections.singleton(T), .
static <E> Iterator<E> Collections.singletonIterator(E e).
hasNext, false, consummer :
static <E> Iterator<E> singletonIterator(final E e) {
...
@Override
public void forEachRemaining(Consumer<? super E> action) {
Objects.requireNonNull(action);
if (hasNext) {
action.accept(e);
hasNext = false;
}
}
...
}
, , .
:
, , .
, forEachRemaining() , , forEachRemaining(), .