Manikandan Thiagarajan
asked on
what is the purpose of hash code and equals method in hashset
what is the purpose of hash code and equals method in hashset
To that matter , hashCode() and equals() method in any Object , is a way of specifying what it means for two objects to be equal .
Say you have two integers 2 and 3 . You simply say they are not equal . But when it comes to Objects , say an Employee object , you have to very clearly put down when you can say two employee objects are equal (or not equal) . hashCode() and equals() are the methods that put down this logic
Say you have two integers 2 and 3 . You simply say they are not equal . But when it comes to Objects , say an Employee object , you have to very clearly put down when you can say two employee objects are equal (or not equal) . hashCode() and equals() are the methods that put down this logic
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.ibm.com/developerworks/java/library/j-jtp05273/index.html