java string enum code example
Example 1: java string enum
package test;
public enum Strings {
STRING_ONE("ONE"),
STRING_TWO("TWO")
;
private final String text;
Strings(final String text) {
this.text = text;
}
@Override
public String toString() {
return text;
}
}
Example 2: c# string enum
public static class Status
{
public const string Awesome = "Awesome";
public const string Cool = "Cool";
}
Example 3: enum with numbers java
public enum EXIT_CODE {
A(104), B(203);
private int numVal;
EXIT_CODE(int numVal) {
this.numVal = numVal;
}
public int getNumVal() {
return numVal;
}
}