Answers for "java 12 switch"

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
0

switch Java 11

switch (profe) {
  case "Anahí":
    System.out.println("¡Profesora de Java!");
    break;
  case "Oscar":
    System.out.println("¡Profesor de React.js!");
    break;
  case "JuanDC":
    System.out.println("Oye niño, ¿qué haces aquí?");
    break;
  default:
    System.out.println("¡Un nuevo profe!");
    break;
}
Posted by: Guest on July-08-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language