Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get integer object from hashmap  RSS feed

 
saket gupta
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...

i m getting the problem with HashMap
i want to get the type of object which i m storing in hashmap
like if we are giving input like this

hm.put("John Doe", new Integer(343));

then i need output like this
==================
<key>
<integer-object>343</integer-object>
</key>
<value>
<string>"John Doe"</string>
</value>
==========================
i m getting the key and value but i want to get the type of object also so i can print like this <integer-object> " " </integer-object>
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your key is the string and your value is the Integer, so your bit of pseudo-XML is wrong. Use the get method to return Objects from a HashMap, and cast the value returned.

(BTW - this would be better in the Java - Beginners forum, rather than the other API forum)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!