Louis I. answered 04/18/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
Hi - no, you cannot - view an enum as sort of a final Class ...
I believe the Java compiler applies some auto-magic to declared enums - e.g.,
public enum Direction {
NORTH, EAST, SOUTH, WEST ;
}
I believe it implicitly extends java.lang.Enum - and so you can't extend another Class or Enum since the language doesn't support multiple inheritance.
I understand why you're asking. It would be nice to declare the following given the above enum
public enum MapDirection extends Direction {
NORTHEAST, SOUTHWEST, NORTHWEST, SOUTHEAST;
}
I'll let you know if I find a clever way to reuse/extend the definition of an existing enum ...
--Lou