public class TestEnums2 { // how and where to declare an enumerated type enum Fruit { APPLE, BERRY, CHERRY, BANANA, GRAPE } enum Move { ROCK, PAPER, SCISSORS } public static void main (String [] args) { int position; // used to hold the position of a value of an enumerated type // how to declare a variable of an enumerated type Fruit myFruit; Move myMove, yourMove; // how to assign an enumerated type value to a enumerated type variable myFruit = Fruit.GRAPE; myMove = Move.ROCK; // illustration of how to output the value stored in an enumerated type variable System.out.println (" My current favorite fruit is " + myFruit); System.out.println (" My current move is " + myMove); // how to determine the position in in the enumerated type of an enumerated value position = myMove.ordinal(); System.out.println (position); position = myFruit.ordinal(); System.out.println (position); // how to compare two enumerated type variables for equality if (myMove.equals (Move.SCISSORS)) System.out.println (" the values are equal "); else System.out.println (" the values are different "); // how to compare two enumerated type variables for relative positions position = myMove.compareTo (Move.PAPER); System.out.println (position); position = myFruit.compareTo (Fruit.CHERRY); System.out.println (position); }// END main } //END class