btms
7/4/2018 - 5:36 PM

Enum with string value

Java Enums with String values.

public enum aEnum {
    aValue ("value"),
    aOtherValue ("string for value"),
    aAddValue ("another value");

    private final String name;       

    private aEnum(String name) {
        this.name = name;
    }

    public boolean equalsName(String otherName) {
          return name.equals(otherName);
    }

    public String toString() {
       return this.name;
    }
}