Java enums are great. So are generics. Of course we all know the limitations of the latter because of type erasure. But there is one thing I don\'t understand, Why can\'t I
There are other methods in ENUM that wouldn't work. What would MyEnum.values() return?
What about MyEnum.valueOf(String name)?
For the valueOf if you think that compiler could make generic method like
public static MyEnum valueOf(String name);
in order to call it like MyEnum, that wouldn't work either.
For example what if you call MyEnum ?
It is not possible to implement that method to work correctly, for example to throw exception or return null when you call it like MyEnum. because of type erasure.