• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can we Pass Primitive data type in HashMap?  RSS feed

 
sumanta panda
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I know in the HashMap the Key and Value is as an Object?

Can we pass Primitive data type in the Hashmap?

If yes please suggest How do you store a primitive data type within a HashMap?

Thanks and Regards,
SPanda
 
John de Michele
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sumanta:

No, you cannot put primitives in any of the Collections classes. However, you can use the wrapper classes, and then use autounboxing.

John.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!