What does //noinspection ForLoopReplaceableByForEach mean?

android, intellij-idea, java

Solution

`//noinspection` is an IntelliJ specific annotation. It's similar to Java's `@SupressWarnings` except that it can be used for a single statement instead of declaring it at class or method level as `@SupressWarnings`.

In this case, it is suppressing the warning that the For loop could be replaced by a ForEach.

Problem

I have been reading some open source libraries which use the following code: ``` //noinspection ForLoopReplaceableByForEach for (int i = 0, count = list.size(); i < count; i++) { // do something } ``` What does `//noinspection ForLoopReplaceableByForEach` mean?

Original source