Free Flowing Switch Statement Example : Switch Statement « Statement Control « Java Tutorial






public class Main {

  public static void main(String[] args) {
    int i = 0;
    switch (i) {

    case 0:
      System.out.println("i is 0");
    case 1:
      System.out.println("i is 1");
    case 2:
      System.out.println("i is 2");
    default:
      System.out.println("Free flowing switch example!");
    }
  }
}
/*
i is 0
i is 1
i is 2
Free flowing switch example!
*/








4.3.Switch Statement
4.3.1.The switch Statement
4.3.2.The switch Statement: a demo
4.3.3.Execute the same statements for several different case labels
4.3.4.Free Flowing Switch Statement Example
4.3.5.Nested Switch Statements Example
4.3.6.Switch statement with enum