Guest User

Untitled

a guest
May 16th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment