Why is this int switch valid:
public class Foo { private final static int ONE = 1; private final static int TWO = 2; public static void main(String
The case argument must be primitive; it cannot be an object.
However, you can use enums as follows:
RetentionPolicy value = ... switch (value) { case RUNTIME: case SOURCE: }
Because value is declared to be of type RetentionPolicy you can use the enum constants directly inside the switch.
value
RetentionPolicy