Link to home
Start Free TrialLog in
Avatar of Manikandan Thiagarajan
Manikandan ThiagarajanFlag for India

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
Avatar of zzynx
zzynx
Flag of Belgium image

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
ASKER CERTIFIED SOLUTION
Avatar of krakatoa
krakatoa
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial