Back to Intellij Community

ConditionalBreakInInfiniteLoop

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

2025.3-rc-2277 B
Original Source

Reports conditional breaks at the beginning or at the end of a loop and suggests adding a loop condition instead to shorten the code.

Example:

while (true) {
    if (i == 23) break;
    i++;
  }

After the quick fix is applied:

while (i != 23) {
    i++;
  }