switch with combined options java code example
Example 1: switch java 11
public String exampleOfSwitch(String animal) {
String result;
switch (animal) {
case "DOG":
result = "domestic animal";
break;
case "CAT":
result = "domestic animal";
break;
case "TIGER":
result = "wild animal";
break;
default:
result = "unknown animal";
break;
}
return result;
}
Example 2: multiple case switch java
switch (variable)
{
case 5:
case 6:
etc.
case 100:
doSomething();
break;
}