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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 namedE), your decompiler isn’t processing generics properly.An enum implicitly extends
Enum<YourEnumType>. That is, implicitly the compiler generates aclass YourEnumType extends Enum<YourEnumType>. By passing down its own type, it allowsEnum‘scompareToandvalueOffunctions to reject values from different types ofenums.