Answers for "switch with combined options java"

3

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;
}
Posted by: Guest on June-10-2020
2

multiple case switch java

switch (variable)
{
    case 5:
    case 6:
    etc.
    case 100:
        doSomething();
    break;
}
Posted by: Guest on October-16-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language