Wednesday, September 24, 2008

equals and hashCode

Whenever we override the equals() method in any class, we must also override the hashCode() method.

if(o1.equals(o2))

then

o1.hashCode() == o2.hashCode()
must also be true.

For more details - http://www.ibm.com/developerworks/java/library/j-jtp05273.html

No comments: