我不确定如何在Java中使用枚举.我在以下示例中正确使用它吗?
enum Sex {M, F};
public class person{
private person mom;
private Sex sex;
public person(Sex sex){
this.sex = sex;
//is this how i'd set sex?
}
public void setMom(person mom){
if(mom.sex == 'M'){}
//is this how i would check to see if the sex of the passed person argument is male?
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3424 次 |
| 最近记录: |