Community
Participate
Working Groups
3.1M6 the method is marked as having an error. This is clearly bogus because the switch is exhaustive. I don't know what the spec says though. (It'd be sad if it enforced the error) public class A { enum Kind {Foo, Bar, Baz} private Kind kind; String getName(){ switch(kind){ case Foo: return "Foo"; case Bar: return "Bar"; case Baz: return "Baz"; } } }
Nice idea but remember that due to binary compatibility, one may add an enum constant, not recompile client code, and suddenly one could traverse the entire switch. Javac agrees with us.