case MyEnum.VALUE1.toString (): // Isn't that equal to "VALUE1"?
No, optional: you can provide your own implementation of toString()
public enum MyType { VALUE1 { public String toString() { return "this is my value one"; } }, VALUE2 { public String toString() { return "this is my value two"; } }
}
In addition, someone who supports your code may add this implementation after leaving the company. This is why you should not rely on String values ββand adhere to the use of numeric values ββ(as represented by the constants MyEnum.VALUE1 , MyEnum.VALUE2 , etc.) of your enum .
dasblinkenlight
source share