java enum

          Posted on 2011-08-01 16:20 xsong 閱讀(220) 評論(0)  編輯  收藏 所屬分類: java
          enum Action {Start, Stop, Rewind, Forward};

          // Special type of class 
          enum Status {
            Flunk(
          50), Pass(70), Excel(90);
            
          private final int value;
            Status(
          int value) { this.value = value; }
            
          public int value() { return value; } 
          };

          Action a 
          = Action.Stop;
          if (a != Action.Start)
            System.out.println(a);               
          // Prints "Stop"

          Status s 
          = Status.Pass;
          System.out.println(s.value());      
          // Prints "70"
          主站蜘蛛池模板: 将乐县| 日照市| 库尔勒市| 田东县| 耿马| 麦盖提县| 西林县| 伊金霍洛旗| 建平县| 五家渠市| 宣城市| 兴化市| 婺源县| 舞阳县| 商水县| 邹城市| 龙山县| 广州市| 万宁市| 开江县| 醴陵市| 方城县| 家居| 石渠县| 无为县| 永宁县| 获嘉县| 丰镇市| 华容县| 临漳县| 邵阳市| 贺兰县| 沁源县| 平原县| 拜城县| 开封市| 平南县| 永寿县| 忻州市| 响水县| 屏南县|