/**
* lets you compare two enums based on the ordinal order
*/
public int compareTo( Enum e );
/**
* enum to ordinal <br>
* tells you where in the order this enum constant fits, first one is 0. The
* compiler automatically generates an ordinal field in each object telling it
* where it belongs in the order.
*/
public int ordinal();
/**
* enum to String <br>
* gets the name of this enum constant as a String. You can also use name() but not getName() or name.
*/
public static String toString();
/**
* String to enum <br>
* turns a String into its corresponding enum constant e.g. converting from
* String to enum, saves reams of ifs or hashMap lookups. The compiler magically
* generates this method for you. You will not find it is the base Enum class.
* If there is no match for the string, it will throw an
* IllegalArgumentException Unfortunately there is no mechanism to give your
* enums aliases for alternate legal string values for the same enum, e.g. true
* yes t y Case sensitive match, no extraneous whitespace permitted in the
* string.
*/
public static EnumType valueOf( String s );
Breed mydog = Breed.valueOf( Breed.class, "Dachshund" );
/**
* get all possible enums
*/
public static EnumType[] values();
Breed myDog = Breed.values()[i];
/**
* Collection of all possible enums
* The compiler builds an array of the enum constants in order, called $VALUES
* that it clones and returns.
* NOTE! This is a static method.
* You can't directly use it in generic code passed an enum value as a parameter.
* You can use Class.getDeclaringClass and Class.getEnumValues in that case.
*/
public static EnumType[] values();
for ( Breed breed : Breed.values() )
{
out.println( breed );
}
/**
* compare to enum types for equality
*/
public static boolean equals( Object o );