daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest May 16th, 2018 103 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top