Code: Select all
switch(s)
{
case Switch.OFF -> System.out.println("It is off!"); break;
}
witch is wrong for java 21, since Java 21, using <enum name>.<constant>is also valid.1. An enum switch case label must be the unqualified name of an enumeration constant. So it should becase OFF instead of case Switch.OFF.