From the implementation point of view the reason is obvious. If an element is a member of an enum and it has a base class, suddenly that object has multiple inheritance, a big NO-NO in Java. On the other hand, if an enum doesn't inherit from any other class the object of class T can inherit from Enum
Implementing it the other way would have been harder; the element would have had to handle methods with the same name, common ancestors, etc., all the nice stuff that make C++ inheritance syntax a huge mess, and really difficult to implement. But then enums would have been useful instead of a quick gimmick for rookies; right now enums are only useful for a simple lists of Strings.
PS: I am not the only Java-enum-hater

No comments:
Post a Comment