js switch case
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
js switch case
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
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"
switch case in javascript
function whatToDrink(time){
var drink ;
switch (time) {
case "morning":
drink = "Tea";
break;
case "evening":
drink = "Shake";
break;
default:
drink="Water";
}
return drink;
}
console.log(whatToDrink("morning")) //Tea
console.log(whatToDrink("evening")) //Shake
console.log(whatToDrink("night")) //Water
console.log(whatToDrink("daytime")) //Water
switch statement in java
// syntax of switch statement in java
switch(expression)
{
case 1 value :
// code goes here
break;
case 2 value :
// code goes here
break;
case 3 value :
// code goes here
break;
.
.
.
.
default: // optional
// default code goes here
}
switch expression java
System.out.println(
switch (day) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> 7;
case THURSDAY, SATURDAY -> 8;
case WEDNESDAY -> 9;
default -> throw new IllegalStateException("Invalid day: " + day);
}
);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us