|Registered:||Jun 06, 2008|
|Given in last 30 days||0|
|Received in last 30 days||0|
|Last 30 days:||0|
book wrote:A natural ordering that uses compareTo() is said to be consistent with equals if, and only if, x.equals(y) is true whenever x.compareTo(y) equals 0.
API doc wrote:The natural ordering for a class C is said to be consistent with equals if and only if e1.compareTo(e2) == 0 has the same boolean value as e1.equals(e2) for every e1 and e2 of class C.
You might be sorting Product objects by name, but names are not unique. Therefore, the return value of compareTo() might not be 0 when comparing two equal Product objects,
so this compareTo() method is not consistent with equals.
Originally posted by Bala'J'i Rags:
COngrats dude..what only a beer!!!