java代码练习 work119

work119.java

package test06;

public class work119
{
	enum Constants4
	{
		A,
		B,
		C,
		D
	}
	
	public static void compare(Constants4 c)
	{
		for (int i = 0; i < Constants4.values().length; i++)
		{
			System.out.println(c + "与" + Constants4.values()[i] + "的比较结果为:" + c.compareTo(Constants4.values()[i]));
		}
	}
	public static void main(String[] args)
	{
		work119.compare(Constants4.valueOf("B"));

	}

}

/*
 * 调用枚举类型Constants4.compareTo方法的结果,
 * 正值表示该对象之前,
 * 0表示位置相同,
 * 负值表示该对象之后
 * 
 */

上一篇:[Kotlin] Compare Functional Programming in Java and Kotlin


下一篇:Java8的新特性--方法引用与构造器引用