Java enum inheritance [duplicate]

Example stolen from here

Because adding elements to an enum
would effectively create a super
class, not a sub class.

Consider:

 enum First {One, Two}   
 enum Second extends First {Three, Four}   

 First a = Second.Four;   // clearly illegal 
 Second a = First.One;  // should work

This is the reverse of the way it
works with regular classes. I guess it
could be implemented that way but it
would be more complicated to implement
than it would seems, and it would
certainly confuse people.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)