Iterator.next() 또는 ListIterator.previous()를 호출하는 Iterator.hasNext() 또는 ListIterator.hasPrevious() 구현을 보고합니다. hasNext()와 같은 메서드는 반복자 상태를 수정하면 안 되는 반면 next()는 수정해야 하므로 그러한 호출은 오류입니다.
예:
class MyIterator implements Iterator<Integer> {
public boolean hasNext() {
return next() != null;
}
}