What exactly is the advantage of enums, considering the following 2 "classes"?
Where lies the advantage in the use of the enum class? In my case here, I don't see a reason to use enums.
StringEnums.class:
package enums;
public enum StringEnum {
HELLO("Hello String :)"),
BYE("Bye String :(");
private final String s;
StringEnum(String s) { this.s = s; }
public final String getValue() {
return s;
}
}
StringNonEnums.class:
package enums;
public class StringNonEnum {
public static final String HELLO = "Hello String :)";
public static final String BYE = "Bye String :(";
}