Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum Color {
- RED(0), BLACK(1);
- int n;
- Color(int n) {
- this.n = n;
- }
- public int getValue() {
- return n;
- }
- public static Color valueOf(int n) {
- Color[] colors = Color.values();
- for (Color c : colors) {
- if (c.getValue() == n) return c;
- }
- return Color.RED;
- }
- }
Add Comment
Please, Sign In to add comment