Getting String value from enum in Java

enums, java

Solution

if `status` is of type `Status` enum, `status.name()` will give you its defined name.

Problem

I have a enum defined like this and I would like to be able to obtain the strings for the individual statuses. How should I write such a method? I can get the int values of the statuses but would like the option of getting the string values from the ints as well. ``` public enum Status { PAUSE(0), START(1), STOP(2); private final int value; private Status(int value) { this.value = value } public int getValue() { return value; } } ```

Original source

Related problems