1int day = 4;
2switch (day) {
3 case 6:
4 System.out.println("Today is Saturday");
5 break;
6 case 7:
7 System.out.println("Today is Sunday");
8 break;
9 default:
10 System.out.println("Looking forward to the Weekend");
11}
12// Outputs "Looking forward to the Weekend"
1System.out.println(
2 switch (day) {
3 case MONDAY, FRIDAY, SUNDAY -> 6;
4 case TUESDAY -> 7;
5 case THURSDAY, SATURDAY -> 8;
6 case WEDNESDAY -> 9;
7 default -> throw new IllegalStateException("Invalid day: " + day);
8 }
9 );
1switch (/*Variable*/)
2{
3 case /*Variable*/:
4 /*Action*/;
5 break;
6 default:
7 /*Action*/;
8}