Reputation: 7417
Isn't it impossible to extend a generic type with an undefined type parameter ex:
class Foo extends enum<E>
How do they extend it?
edit: also where is the values() method defined?
Thanks in advance
Upvotes: 1
Views: 150
Reputation: 231283
It is indeed illegal to extend a generic type with an undefined type parameter. However, enums don't do that. If you're decompiling some java code and saw a <E>
there (And your enum type is not named E
), your decompiler isn't processing generics properly.
An enum implicitly extends Enum<YourEnumType>
. That is, implicitly the compiler generates a class YourEnumType extends Enum<YourEnumType>
. By passing down its own type, it allows Enum
's compareTo
and valueOf
functions to reject values from different types of enum
s.
Upvotes: 5