Answers for "switch case statements java"

83

java switch

int day = 4;
switch (day) {
  case 6:
    System.out.println("Today is Saturday");
    break;
  case 7:
    System.out.println("Today is Sunday");
    break;
  default:
    System.out.println("Looking forward to the Weekend");
}
// Outputs "Looking forward to the Weekend"
Posted by: Guest on March-11-2020
0

switch expression java

System.out.println(
        switch (day) {
            case MONDAY, FRIDAY, SUNDAY -> 6;
            case TUESDAY                -> 7;
            case THURSDAY, SATURDAY     -> 8;
            case WEDNESDAY              -> 9;
            default -> throw new IllegalStateException("Invalid day: " + day);
        }
    );
Posted by: Guest on September-30-2020
0

switch en java

switch (/*Variable*/)
{
  case /*Variable*/:
    /*Action*/;
    break;        
  default:
    /*Action*/;             
}
Posted by: Guest on February-10-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language