I created a very basic enum
public enum StatusCode {
OK(0, "Everything ran correctly"),
ERROR(4, "Fatal Error");
private final int value;
private final String description;
StatusCode(final int value, final String description) {
this.value = value;
this.description = description;
}
public int getValue() { return value; }
public String getDescription() { return description; }
}
In my method I'm trying to return a integer
public Integer func() {
return StatusCode.OK; // Inside method
}
ERROR:
Type mismatch: cannot convert from StatusCode to Integer
I know I can do StatusCode.OK.getValue()
but it looks weird. How can StatusCode.OK
be an integer by default?