wood burning stoves*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "hashcode()..." Watch "hashcode()..." New topic
Author

hashcode()...

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
Greenhorn

Joined: Dec 02, 2008
Posts: 15
Hi,

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.

Anand.
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.

Bye
<><


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