Back to Intellij Community

UnnecessaryLabelOnBreakStatement

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

2025.3-rc-2376 B
Original Source

Reports break statements with unnecessary labels. Such labels do not change the control flow but make the code difficult to follow.

Example:

label:
  for(int i = 0; i < 10; i++) {
    if (shouldBreak()) break label;
    //doSmth
  }

After the quick-fix is applied:

label:
  for(int i = 0; i < 10; i++) {
    if (shouldBreak()) break;
    //doSmth
  }