Files
openide/java/java-impl/resources/inspectionDescriptions/WhileCanBeForeach.html
2025-02-05 04:43:28 +00:00

22 lines
590 B
HTML

<html>
<body>
Reports <code>while</code> loops that iterate
over collections and can be replaced with enhanced <code>for</code> loops (foreach iteration syntax).
<!-- 'foreach' still used in this description so that the inspection continues to be found using this keyword -->
<p><b>Example:</b></p>
<pre><code>
Iterator it = c.iterator();
while(it.hasNext()) {
Object obj = it.next();
System.out.println(obj);
}
</code></pre>
<p>Can be replaced with:</p>
<pre><code>
for (Object obj : c) {
System.out.println(obj);
}
</code></pre>
<!-- tooltip end -->
</body>
</html>