File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding equals() & hashcode() in collections

 
ramya narayanan
Ranch Hand
Posts: 338
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Regards.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic