Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hashmap

 
tom brownlee
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i put an object as the value in a hashmap
eg
hashMap.put("some key" , Object);
in my code i have a user enter in a jewel color where it should look up the hash table with the jewel colour as the key returning the jewel as an object in which i can then manipulate with other methods.
how do i do this?
thankyou
 
Marilyn de Queiroz
Sheriff
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hashMap.put("some key" , new Object());
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to be asking to different questions at the same time. First you say you want to "put" a value, this implies you wish to assign an value into the hashmap. Than you say you want to "look up", which implies you want to extract a value.
The answer to assigning a value was posting by Marilyn.
To extract a value you can the "get" method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic