枚举简单例子
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);
}
}
}
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);
}
}
}
相关文章推荐
- 下拉刷新功能实现
- CMFCMenubar 动态添加菜单项
- fullPage.js插件使用(一)
- 定义block
- 淘宝改变了我们
- Oracle 备份与还原
- 汶川地震亲历者:唯有经历过惊惶失策,才不至于“花容失色"
- 鸟哥的Linux私房菜笔记(二)
- 软件常见版本解释
- JAVA虚拟机、Dalvik虚拟机和ART虚拟机简要对比
- MFC中的CMenu---如何动态添加菜单/菜单项、子菜单、右键菜单
- iOS设置tableViewCell的cell、textLabel和detailTextLabel背景颜色
- js中数组 与 对象的区别
- 网站性能构建
- 用例分析
- 这九年来都在干嘛-兄弟连IT教育
- mysql使用in查询,按照期望的顺序输出结果
- jndi 数据源
- SpringMVC集成velocity模版
- 时间戳引起的网站访问不了的问题(net.ipv4.tcp_timestamps)