Language syntax

Java switch fall-through

Traditional statement groups can continue through later labels without break. Adjacent empty labels share an action, as shown here; the syntax illustrates fall-through between nonempty groups.

Formal Syntax & Structure

java syntaxjava
case first: statement; case second: statement; break;

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) {        int n = 1;        switch (n) { case 1: case 2: System.out.println("Group"); break; default: System.out.println("Other"); }    }}
Java Reference