您的位置:首页 > 其它

枚举简单例子

2015-12-31 11:44 281 查看
public class EnumTest {
public enum Month{
JANUARY("january",1),FEBRUARY("February",2),MARCH("March",3),APRIL("April",4);
private String mMonth;
private int mValue;
Month(String month,int value) {
this.mMonth = month;
this.mValue = value;
}
public static void getAllValues(){
for(Month month:values()){
month.IsJanuary();
}
}

public void IsJanuary(){
if(mMonth.equals("january")){
System.out.println(mMonth);
}
}
}
public static void main(String[] args) {
Month.getAllValues();
Month month = Month.FEBRUARY;
if(month == Month.FEBRUARY){
System.out.println(month.mValue);
}
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: