码迷,mamicode.com
首页 > 编程语言 > 详细

java中使用枚举类型,代码如下

时间:2016-09-26 20:04:23      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

public enum CommonStatus {
    NORMAL(1), PAUSE(2), DELETE(3);
    private int value;
    private CommonStatus(int v) {
        this.value = v;
    }
    
    public int getValue() {
        return value;
    }
    
    public static String getName(int v) {
        switch (v) {
        case 1:
            return "正常";
        case 2:
            return "停用";
        case 3:
            return "删除";
        default:
            return "";
        }
    }
    
    public static String getName(CommonStatus s) {
        return getName(s.getValue());
    }
}

java中使用枚举类型,代码如下

标签:

原文地址:http://www.cnblogs.com/baobaodaren/p/5910228.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!