public enum Color { RED, BLUE, BLACK, YELLOW, GREEN }
public class Program { //RED, BLUE, BLACK, YELLOW, GREEN public static void main(String[] args) { // testOrdinal(); testCompareTo(); } public static void testCompareTo(){ int dis=Color.GREEN.compareTo(Color.RED); System.out.println(dis); } public static void testOrdinal(){ System.out.println(Color.YELLOW.ordinal()); System.out.println(Color.GREEN.ordinal()); System.out.println(Color.RED.ordinal()); System.out.println(Color.BLUE.ordinal()); System.out.println(Color.BLACK.ordinal()); } }