This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes primitive datatype in HashMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "primitive datatype in HashMap" Watch "primitive datatype in HashMap" New topic
Author

primitive datatype in HashMap

priyanaka jaiswal
Ranch Hand

Joined: Jun 03, 2011
Posts: 79
Hi,


Can we use primitive data type as Key and value pair in Hashmap instead of object?


Thanks in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 62317
    
  68

No, but with autoboxing it appears as if you can. But in reality, only objects can be stored in a HashMap.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: primitive datatype in HashMap