Java Enum - . :
public enum ErrorCodes {
Undefined, Defined, Foo, Bar
}
, :
public class ErrorCodes {
public final static ErrorCodes Undefined = new ErrorCodes();
public final static ErrorCodes Defined = new ErrorCodes();
public final static ErrorCodes Foo = new ErrorCodes();
public final static ErrorCodes Bar = new ErrorCodes();
}
enum.
The sun was so kind that it allowed us to add fields that follow the definition of eunum members: public enum ErrorCodes {Undefined, Defined, Foo, Bar; private String myField; }
That is why your custom code should always be defined after the enumeration fields.
source
share