Back to Intellij Community

NestedSwitchStatement

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

2025.3-rc-2364 B
Original Source

Reports nested switch statements or expressions.

Nested switch statements may result in extremely confusing code. These statements may be extracted to a separate method.

Example:

int res = switch (i) {
            case 0 -> 0;
            default -> switch (i) {
                case 100 -> 0;
                default -> i;
            };
        };