Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Hashcode Question

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
in the exam objectives it says to know the correct implementations of hashcode.

In the s&b there is a table which shiws the rules for hashCode to follow.that is if 2 objects r equal their hashCode msut be equal not vic e versa.
what else hsould we know for the exam.
waht does it mean correct and incorrect implementations of the hashCode to know for the exam?
thanks in advance.
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should know the hashCode contract. The following 2 rules are a MUST :-

1. if a.equals(b) is true, then a.hashCode() MUST be equal to b.hashCode()
2. If a.hashCode() and b.hashCode() are not equal, then a.equals(b) MUST be false

the remaining combinations are not mandatory. If you know & understand this, you should be able to answer all equals & hashCode questions correctly.
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic