Hi,
Was playing with some generics and
java's enums earlier and can't figure out why the code below gives me a compile error about the 'values()' method call.
It's saying that :-
the method values() is undefined for the type E
But I thought since a java enum implicitly extends Enum and values() is a static method given by using an enum type, there's no reason the below wouldn't work (as I've stated that E is extending Enum). Anybody have any suggestions or have any reason why it's giving me that error?
Note : Interestingly I did take a look at the Java API (1.6) and it looks like Enum doesn't actually have the values() method specified??? So if this is the case where does a java enum get the values() method from (so should my extends be extending that?) or is it some real trickery done by the compiler (thus the code below cannot be fixed?). I did notice that if I use any of the methods from the Enum Api declarations, they compile)
Any help would be much appreciated.
Ps. Before anybody comments, I know the below code isn't really logical since I could use valueOf(...) to do the same but its meant as an illustrative example of what I'm really doing so please don't comment on that and only post if you have something about my actual question.