Interface LookaheadIterator<E>
- All Known Implementing Classes:
PeekingIterator
public interface LookaheadIterator<E>
-
Method Summary
-
Method Details
-
peek
E peek()Returns the next element in iteration without advancing the underlying iterator. If the iterator is already exhausted, null will be returned.Note: this method does not throw a
NoSuchElementException
if the iterator is already exhausted. If you want such a behavior, useelement()
instead.The rationale behind this is to follow the
Queue
interface which uses the same terminology.- Returns:
- the next element from the iterator
-
element
E element()Returns the next element in iteration without advancing the underlying iterator. If the iterator is already exhausted, null will be returned.- Returns:
- the next element from the iterator
- Throws:
NoSuchElementException
- if the iterator is already exhausted according toinvalid reference
#hasNext()
-