This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
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 Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections : Help Needed" Watch "Collections : Help Needed" New topic

Collections : Help Needed

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 392
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

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:
subject: Collections : Help Needed
It's not a secret anymore!