Possible Duplicate:
add values to enum
Why enums in Java cannot inherit from other enums? Why is this implemented this way?
Java Enum and Interface As we have learned, we cannot inherit enum classes in Java. However, enum classes can implement interfaces.
Nope. it is not possible. Enum can not inherit in derived class because by default Enum is sealed.
No, we cannot extend an enum in Java. Java enums can extend java. lang. Enum class implicitly, so enum types cannot extend another class.
Enum. Since Java does not support multiple inheritance, an enum cannot extend anything else.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With