File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Overriding equals() & hashcode() in collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Overriding equals() & hashcode() in collections" Watch "Overriding equals() & hashcode() in collections" New topic

Overriding equals() & hashcode() in collections

ramya narayanan
Ranch Hand

Joined: Oct 06, 2008
Posts: 338
Dear all,
What is the need for overriding equals() & hashcode() in Collections .
Normally every instance by default inherits Object class which has equals() & hashcode() . Then why we should override it?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46437
java NameDemo ramya ramya

See what comes out. You need to have two identical objects recoognised as identical to each other for the Collections to work.
I agree. Here's the link:
subject: Overriding equals() & hashcode() in collections
jQuery in Action, 3rd edition