首页 > 编程语言 > 详细

Enum

时间:2020-04-02 18:27:20      阅读:63      评论:0      收藏:0      [点我收藏+]

 

public enum GenderEnum {
    MAN("1","男"),
    WOMAN("2","女");

    GenderEnum(String code,String codeName){
        this.code = code;
        this.codeName = codeName;
    }

    public static String getGenderNameByCode(String code){
        String codeName;
        switch (code){
            case "1":
                codeName = GenderEnum.MAN.codeName;
                break;
            case "2":
                codeName = GenderEnum.WOMAN.codeName;
                break;
                default:
                    codeName = "未知";
        }
        return codeName;
    }

    private String code;
    private String codeName;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCodeName() {
        return codeName;
    }

    public void setCodeName(String codeName) {
        this.codeName = codeName;
    }
}

 

Enum

原文:https://www.cnblogs.com/lijianda/p/12621281.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!