//*****************************************************************************
// enum example 
//*****************************************************************************
public class enum1 
{
    enum Gender  {male, female};
    enum Rainbow {red, orange, yellow, green, blue, indigo, violet};

    public static void main(String[] args)
    {
        Gender  sex;                                    //create a gender variable
        Rainbow color1, color2;                         //create 2 rainbow variables
 
        sex = Gender.male;                              //assign a value to sex variable
        System.out.println(sex);

        sex = Gender.valueOf("female");                 //another way to assign a value
        System.out.println(sex);

        color1 = Rainbow.orange;                        //assign a value to color1 variable            
        System.out.println(color1);

        color2 = Rainbow.valueOf("green");              //another way to assign a value
        System.out.println(color2);

        System.out.println();

        Rainbow allValues[] = Rainbow.values();         //create an array of all the Rainbow values
        for (Rainbow clr : allValues)                   //print all those values
            System.out.println(clr);

        System.out.println();

        if (color1.equals(color2))                      //compare to Rainbow variables
            System.out.println(true);
        else
            System.out.println(false);

       String str = color1.toString();                  //convert to a String
       System.out.println(str);
    }
}