This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes hashcode()... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "hashcode()..." Watch "hashcode()..." New topic


Ganeshkumar cheekati
Ranch Hand

Joined: Oct 13, 2008
Posts: 362
In some questions he has given code for equals method for which he is asking us to select most appropiate hashcode method from given choices?

how can we answer these types of questions?

can anyone explain with simple example?

SCJP5 and SCWCD1.5
Think Twice Act Wise...
anand-k jha

Joined: Dec 02, 2008
Posts: 15

Please look below example:

Hashcode always will return a fixed value for an object, so
Second method is not appropriate here.
I think this will help you.

Djonatah Stiegler
Ranch Hand

Joined: Oct 30, 2008
Posts: 32
I think you should choose the hashCode() method that uses the same variables used on the equals() method.


From Brazil
I agree. Here's the link:
subject: hashcode()...
Similar Threads
variables in hashCode( ) and equals( )
Doubt on String Comparisson
hashCode() usage
hash code problem