/* SWITCH switch(expr) { case constant: statements; break; .... default: stratements; } Expression: must be int, short, char, byte Constants: must be *compile-time* constants. So, no variables! (which are set at run-time) */ public class TestSwitch { public static void main(String[] args) { for (int i=0;i<=4;i++) { switch (i) { case 0: System.out.println("0!"); break; case 1: System.out.println("1!"); break; case 2: System.out.println("2 is bad!"); case 3: System.out.println("3! This is what happens "+ "with no break!"); break; default: System.out.println("int not known!"); } } } } /* Output: 0! 1! 2 is bad! 3! This is what happens with no break! 3! This is what happens with no break! int not known! */