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; } }