Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections : Help Needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections : Help Needed" Watch "Collections : Help Needed" New topic
Author

Collections : Help Needed

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
In K&B Book page -614, Question -7. I have 2 questions

1. Please let me know where is the explaination related to this question in present in the entire chapter.

2. If no hashcode() then each will go in it's own bucket, then no question of equal() comes into picture. But if hashcode present will duplicate keys (equals()) will be detected @ compile time or runtime. I think @ runtime . Please correct me if i am wrong.

Please put some more light on the expaination...


Thanks in advance.
Alina Petra
Greenhorn

Joined: Oct 17, 2006
Posts: 26
1. I think that reading Using Maps section (page 563) would help.

2. t1.equals(t2) returns false because the hashCode() is not overriden, therefore the output will be 3.
But if the hashCode() is overriden, then t1.equals(t2) will return true, therefore the output will be 2.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collections : Help Needed
 
Similar Threads
equal() and hashcode()..
TreeSet uses compareTo
hashCode() problem
Help me with equals! - I've exam tomorrow
hashcode question