syntax for switch in java code example
Example 1: java switch
int day = 4;
switch (day) {
case 6:
System.out.println("Today is Saturday");
break;
case 7:
System.out.println("Today is Sunday");
break;
default:
System.out.println("Looking forward to the Weekend");
}
// Outputs "Looking forward to the Weekend"
Example 2: switch en java
switch (/*Variable*/)
{
case /*Variable*/:
/*Action*/;
break;
default:
/*Action*/;
}