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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -