Back to Intellij Community

LoopConditionNotUpdatedInsideLoop

java/java-impl/resources/inspectionDescriptions/LoopConditionNotUpdatedInsideLoop.html

2025.3-rc-2560 B
Original Source

Reports any variables and parameters that are used in a loop condition and are not updated inside the loop.

Such variables and parameters are usually used by mistake as they may cause an infinite loop if they are executed.

Example:

void loopDoesNotLoop(boolean b) {
    while (b) {
      System.out.println();
      break;
    }
  }

Configure the inspection:

Use the Ignore possible non-local changes option to disable this inspection if the condition can be updated indirectly (e.g. via the called method or concurrently from another thread).