File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collections : Help Needed

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic