Win a copy of Rust Web Development this week in the Other Languages 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Hashcode Question

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic