package ming; enum Gender{ MALE("男"),FEMALE("女"); //public static final Gender MALE = new Gender("男"); private String name; public String getName() { return name; } private Gender(String name) { this.name=name; } } public class enumTest { public static void main(String[] args) { // 通过valueof方法获取指定枚举类的值 Gender gf = Enum.valueOf(Gender.class, "FEMALE"); Gender gm = Enum.valueOf(Gender.class, "MALE"); System.out.println(gf+" is stand for "+gf.getName()); System.out.println(gm+" is stand for "+gm.getName()); } }