import java.util.* ; import java.time.* ; public class Switch { public static void main( String args[] ) { int x1 = 5 ; int y1 = 5 ; //System.out.println( "Enter a value between 1 and 10" ) ; //Scanner scanner = new Scanner(System.in); // Get today's date LocalDate today = LocalDate.now(); // Get the DayOfWeek enum instance int dayNo = today.getDayOfWeek().getValue() ; System.out.println( "dayNo: " + dayNo ) ; String day = "" ; switch ( dayNo ) { case 1: day = "Monday"; break; case 2: day = "Tuesday"; break; case 3: day = "Wednesday"; break; case 4: day = "Thursday"; break; case 5: day = "Friday"; break; case 6: day = "Saturday"; case 7: day = "Sunday"; break; } System.out.println( "Today's day is :" + day ) ; //System.out.println( "----" ) //Without break the control continues x1 = 0 ; switch ( x1 ) { case 0: System.out.println( "Sunday" ) ; case 1: System.out.println( "Monday" ) ; case 2: System.out.println( "Tuesday" ) ; break; } System.out.println( "----" ) ; //multiple case statements //share same code block switch ( x1 ) { case 0: case 1: System.out.println( "x1 is 0" ) ; System.out.println( "x1 is 1" ) ; break ; case 2: System.out.println( "x1 is 2" ) ; break; } System.out.println( "----" ) ; //default case statement is executed //if there is no match. x1 = 5 ; switch ( x1 ) { case 0: System.out.println( "x1 is 0" ) ; break ; case 1: System.out.println( "x1 is 1" ) ; break ; case 2: System.out.println( "x1 is 2" ) ; break; default: System.out.println( "x1 is something else." ) ; } } } //class