I have an enum
with a constructor:
enum myEnum {
A(0), B(1), C(2);
private final short value;
private myEnum(short value) {
this.value = value;
}
public short getValue() {
return this.value;
}
}
Unfortunately, Eclipse is letting me know that there is no constructor accepting a single int
. Therefore I am relegated to casting to a short...
A((short) 0), B((short) 1), C((short) 2);
...whether this is done for each value or taking an int
in the constructor and casting at assignment.
Is there a better way to do this than taking the time to cast, or is there no better solution?