The class java.lang.Enum
declare both equals()
and hashCode()
as final
, thus you'll get compiler errors trying to override them.
That being said, your example above works as you desire - if you add AlphaTypes.Common
and BetaTypes.Common
to a Map
you'll get a map with two elements:
public static void main( String[] args ) throws Exception
{
Map<Types,Object> map = new HashMap<Types,Object>();
map.put( AlphaTypes.Common , "b" );
map.put( BetaTypes.Common , "b" );
System.out.println( "size=" + map.size());
}
size=2
Cheers,