Fill in the missing case statement

Report a typo

Fill in the blank to complete the switch expression. Your added case statement should return 3 in case your hungry level is 10. Use arrow notation.

int numberOfHamburgersToEat = switch (howHungryAmI) {
    case 1, 2, 3 -> 0;                  

    case 4, 5, 6 -> {                   
        yield 1;
    }

    case 7, 8, 9 -> {                   
        System.out.println(2);
        yield 2;
    }

    _________________________

    default -> throw new Exception("The number must be between 1 and 10");
};
Enter a short text
___

Create a free account to access the full topic