java.lang.Enum<E>
. Since java doesn't allow multiple inheritance, enum types can't have superclass. They can't even extend from java.lang.Enum
, nor java.lang.Object
. It also means enum A can't inherit or extend enum B.For example, the following is an invalid enum declaration:
public enum MyType extends Object {Compiler error:
ONE, TWO
}
MyType.java:3: '{' expectedThe correct form should be:
public enum MyType extends Object {
MyType.java:6: identifier expected
2 errors
public enum MyType {More posts about java enum:
ONE, TWO
}
- Java enum examples
- Custom String Values for Enum
- Enum wrapper for javax.transaction.Status
- Enum wrapper for javax.transaction.Status (2)
Tags: