Why is this an issue?

A for loop with a counter that moves in the wrong direction, away from the stop condition, is not an infinite loop. Because of wraparound, the loop will eventually reach its stop condition, but in doing so, it will probably run more times than anticipated, potentially causing unexpected behavior.

How to fix it

Code examples

Noncompliant code example

public void doSomething(String [] strings) {
  for (int i = 0; i < strings.length; i--) { // Noncompliant
    String string = strings[i];  // ArrayIndexOutOfBoundsException when i reaches -1
    //...
  }

Compliant solution

public void doSomething(String [] strings) {
  for (int i = 0; i < strings.length; i++) {
    String string = strings[i];
    //...
  }

Resources

Documentation