mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
26 lines
663 B
HTML
26 lines
663 B
HTML
<html>
|
|
<body>
|
|
Reports implementations of <code>Iterator.next()</code>
|
|
that cannot throw <code>java.util.NoSuchElementException</code>.
|
|
<p>
|
|
Such implementations violate the contract of <code>java.util.Iterator</code>,
|
|
and may result in subtle bugs if the iterator is used in a non-standard way.
|
|
</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
class Numbers implements Iterator<Integer> {
|
|
@Override
|
|
public Integer next() { //warning
|
|
if (hasNext()) {
|
|
return generateNext();
|
|
} else {
|
|
return null; //throw NoSuchElementException instead
|
|
}
|
|
}
|
|
|
|
...
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |