daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest May 16th, 2018 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public enum Color {
  2.     RED(0), BLACK(1);
  3.     int n;
  4.     Color(int n) {
  5.         this.n = n;
  6.     }
  7.     public int getValue() {
  8.         return n;
  9.     }
  10.     public static Color valueOf(int n) {
  11.         Color[] colors = Color.values();
  12.         for (Color c : colors) {
  13.             if (c.getValue() == n) return c;
  14.         }
  15.         return Color.RED;
  16.     }
  17. }
RAW Paste Data
Top