Java Collection Framework
Java Collection Framework
Two enumeration constants can be compared for equality by using the == relational
operator.
You can compare for equality an enumeration constant with any other object by using
equals( ),
which overrides the equals( ) method defined by Object.
Although equals( ) can compare an enumeration constant to any other object, those
two objects
will be equal only if they both refer to the same constant,within the same
enumeration.
Simply having ordinal values in common will not cause equals( ) to return true if
the two constants
are from different enumerations. Remember, you can compare two enumeration
references for equality by using ==.