java - How to use enums? -
i'm not sure how use enum in java. using right in following example?
enum sex {m, f}; public class person{ private person mom; private sex sex; public person(sex sex){ this.sex = sex; //is how i'd set sex? } public void setmom(person mom){ if(mom.sex == 'm'){} //is how check see if sex of passed person argument male? } }
this want use:
if(mom.sex == sex.m)
however, spell out enum constants male , female.
Comments
Post a Comment