aspose file tools*
The moose likes Beginning Java and the fly likes hashmap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "hashmap" Watch "hashmap" New topic
Author

hashmap

tom brownlee
Greenhorn

Joined: Aug 14, 2001
Posts: 28
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

Joined: Jul 22, 2000
Posts: 9047
    
  10
hashMap.put("some key" , new Object());


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

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.


Please ignore post, I have no idea what I am talking about.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hashmap