1public class DaysOfTheWeek {
2
3 public enum Days {m, t, w, r, f, sat, s};
4 public static void main(String[] args) {
5 Days d = Days.t;
6 System.out.println(d);
7 //the output would be t
8 }
9}
1public enum Feu {
2
3 VERT(0), ORANGE(1), ROUGE(2);
4
5
6 private int value;
7
8 private Feu( int value ) {
9 this.value = value;
10 }
11
12 public int toInt() {
13 return value;
14 }
15
16 public static Feu fromInt( int value ) {
17 switch( value ) {
18 case 0: return VERT;
19 case 1: return ORANGE;
20 default: return ROUGE;
21 }
22 }
23
24}
25