⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enuminclass.java

📁 Java面向对象编程(随书配套源代码) 阐述了面向对象编程的思想
💻 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 + -