Back to Intellij Community

BreakStatement

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

2025.3-rc-2309 B
Original Source

Reports break statements that are used in places other than at the end of a switch statement branch.

break statements complicate refactoring and can be confusing.

Example:

void foo(List<String> strs) {
  for (String str : strs) {
    if (str.contains("stop")) break;
    handleStr(str);
  }
}