@ Override public Iterator < E > iterator ( ) { return new Iterator < E > ( ) { /** * The index to indicate the current position * of this iterator. * * The starting point is set to the current * value of this stream's offset, so that it * doesn't iterate over consumed elements. */ private int index = offset ; /** * {@inheritDoc} */ @ Override public boolean hasNext ( ) { return index < elements . length ; } /** * {@inheritDoc} */ @ Override public E next ( ) { if ( index >= elements . length ) { throw new NoSuchElementException ( ) ; } return elements [ index ++ ] ; } /** * {@inheritDoc} */ @ Override public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; }
Returns an iterator over elements that are left in this stream .