Java is not accepting "break" in switch statement

159 views Asked by At

I trying to insert "break" code in switch statement in java for stop looping output. I insert the break in switch statement, but the java is giving the "break is unusual statement" and break is greyed out.

switch (Stardose) {
    case "Student", "student" -> System.out.println(Stardose = "Student");
    case "Office", "office" -> System.out.println(Stardose = "Office");
    case "Pro", "pro" -> System.out.println(Stardose = "Pro");
    case "Xstream", "xstream" -> System.out.println(Stardose = "Xstream");
    default -> throw new IllegalArgumentException("Invalid edition " + Stardose);
}
0

There are 0 answers