public enum Gender {
male("男n"){
public String getAge(){
return "255";
}
},female("女n"){
public String getAge(){
return "233";
}
};
private String val;
private Gender(String val){
this.val = val;
}
public String getVal(){
return this.val;
}
public abstract String getAge();
}
public class GenderTest {
public static void main(String[] args) {
Gender m = Gender.male;
System.out.println("m" + m.getAge());
Gender m2 = Gender.female;
System.out.println(m2.getAge());
}
|