Language syntax
Java switch arrow rules
Group alternative constants and execute only the matched rule. Permanent since Java 14.
Formal Syntax & Structure
java syntaxjava
case first, second -> statement;Working Example
Example Snippetjava
public class Main { public static void main(String[] args) { int n = 3; switch (n) { case 2, 3 -> System.out.println("Group"); default -> System.out.println("Other"); } }}