Inspectopedia
 
2024.3

'Iterator.hasNext()' which calls 'next()'

Warning
New
Last modified: 03 December 2024

Reports implementations of Iterator.hasNext() or ListIterator.hasPrevious() that call Iterator.next() or ListIterator.previous() on the iterator instance. Such calls are almost certainly an error, as methods like hasNext() should not modify the iterators state, while next() should.

Example: