Java examples for Language Basics:switch
Demonstration of the switch case statement
public class Main { public static void main(String arg[]) { int dd = 3; // 0 for Monday , 6 for Sunday switch (dd) { case 0:/* w w w .j a v a2s . co m*/ System.out.println("Monday"); break; case 1: System.out.println("Tuesday"); break; case 2: System.out.println("Wednesday"); break; case 3: System.out.println("Thursday"); break; case 4: System.out.println("Friday"); break; case 5: System.out.println("Saturday"); break; case 6: System.out.println("Sunday"); break; default: System.out.println("Out of scope!"); } } }