📄 enuminclass.java
字号:
package chapter7;
public class EnumInClass
{
private int i =0;
public enum Month //只允许使用存取修饰符、static、abstract
{
January("Jan") ,February("Feb"),March("Mar"),April("Apr"),May("May"),
June("June"),July("July"),August("Aug"),September("Sept"),October("Oct"),November("Nov"),December("Dec");
public String abbreviation = "";
Month(String abbreviation) //枚举构造函数只能private,默认也为private
{
this.abbreviation = abbreviation;
}
public static void display()
{
for(Month m : Month.values())
{
System.out.println(m.ordinal() +" " + m.abbreviation);
}
}
public void out()
{
System.out.println(this.abbreviation);
}
}
public static void display()
{
Month.display();
}
public static void main(String args[])
{
EnumInClass.display();
Month.April.out();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -