性别Sex、YesOrNo 采用枚举的方式实现

Sex

/**
 * 性别枚举
 */
public enum Sex {
     
    woman(0,"女"),
    man(1,"男"),
    secret(2,"保密");

    public final int type;
    public final String value;

    Sex(int type, String value) {
     
        this.type = type;
        this.value = value;
    }
}

YesOrNo

/**
 * YesOrNo枚举
 */
public enum YesOrNo {
     
    NO(0,"否"),
    Yes(1,"是");


    public final int type;
    public final String value;

    YesOrNo(int type, String value) {
     
        this.type = type;
        this.value = value;
    }
}

你可能感兴趣的:(java)