'while' loop can be replaced with enhanced 'for' loop
Reports while
loops that iterate over collections and can be replaced with enhanced for
loops (foreach iteration syntax).
Example:
Iterator it = c.iterator();
while(it.hasNext()) {
Object obj = it.next();
System.out.println(obj);
}
Can be replaced with:
for (Object obj : c) {
System.out.println(obj);
}
This inspection only reports if the language level of the project or module is 5 or higher.
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023