• Post Reply Bookmark Topic Watch Topic
  • New Topic

Expain me what is hashCode() method  RSS feed

 
sandip sangale
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


1) why to override hashCode() method
we what difference it makes when override.
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See why we need to override hashcode when write equality method in Java here

 
Alessandro Ilardo
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The article actually says how to override those methods, not why we should.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alessandro Ilardo wrote:The article actually says how to override those methods, not why we should.

Really? Pitfall #2 in the article explains quite clearly what hashCode() is used for, so this makes it clear when and why you should implement a hashCode() method.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!