Answers for "java 15 switch statement example"

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

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language