Java教程

java代码练习 work122

本文主要是介绍java代码练习 work122,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

work122.java

package test07;

public class work122
{

	enum Constants7
	{
		A("成员A"),
		B("成员B"),
		C("成员C"),
		D(4);
		
		private String note;
		private int i = 4;
		
		private Constants7()
		{
			
		}
		
		private Constants7(String note)
		{
			this.note = note;
		}
		
		private Constants7(int i)
		{
			this.i = this.i + i;
		}
		
		public String getNote()
		{
			return this.note;
		}
		
		public int getI()
		{
			return this.i;
		}
	}
	
	public static void main(String[] args)
	{
		for (int i = 0; i < Constants7.values().length; i++)
		{
			System.out.println(Constants7.values()[i] + "调用getNote方法:" + Constants7.values()[i].getNote());
		}
		System.out.println(Constants7.valueOf("D") + "调用getI方法:" + Constants7.valueOf("D").getI());
	}

}

这篇关于java代码练习 work122的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!