• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashMap

 
Ravi Kiran
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can any one please explain me why hashmap is allowing a single null key, whats the benefit by having a single null key?
 
Vinoth Kumar Kannan
Ranch Hand
Posts: 276
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi, you know what...I too was wondering what the answer might be and did a google on this. To my surprise, the first link was from CodeRanch. This seems to have been already discussed here. A convincingly good thread, actually..
http://www.coderanch.com/t/385836/java/java/Why-HashMap-allows-add-one
 
Ravi Kiran
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot vinoth,

a very useful link you posted..


Thanks,
Ravi
 
Vinoth Kumar Kannan
Ranch Hand
Posts: 276
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Campbell Ritchie
Sheriff
Posts: 48374
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We only have good threads here (and if you believe that, you will believe anything )

HashMap is a library class; as people implied on that thread, a library class should be provided with all possible actions, As Joanne Neal (who is an asset to this website) said, it is easy to wrap HashMap to prohibit null keys (or also prohibit null values) but not to permit nulls if the enclosed class prohibits nulls.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Joanne Neal (who is an asset to this website)


Careful. You'll have Rob complaining about us flirting again. You know how jealous he gets.
 
Campbell Ritchie
Sheriff
Posts: 48374
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jealous of whom?
 
Rob Spoor
Sheriff
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meh, I know Campbell is already happily married. Besides, my girlfriend won't allow me to become jealous
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Besides, my girlfriend won't allow me to become jealous


I'm glad to know she's got you so well trained.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic