Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Expain me what is hashCode() method

 
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
Saloon Keeper
Pie
Posts: 15437
41
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic