Inspectopedia Help

'' which can't throw 'NoSuchElementException'

Reports implementations of that cannot throw java.util.NoSuchElementException.

Such implementations violate the contract of java.util.Iterator, and may result in subtle bugs if the iterator is used in a non-standard way.


class Numbers implements Iterator<Integer> { @Override public Integer next() { //warning if (hasNext()) { return generateNext(); } else { return null; //throw NoSuchElementException instead } } ... }

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024