aspose file tools*
The moose likes Beginning Java and the fly likes Hashtable getting value without knowing the key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hashtable getting value without knowing the key" Watch "Hashtable getting value without knowing the key" New topic
Author

Hashtable getting value without knowing the key

Sebastian Green
Ranch Hand

Joined: Jan 30, 2004
Posts: 136
Hi, Im storing vectors in a hashtable. The key is an unique name. How do I get the value without using the keyname like:
Integer n = (Integer)numbers.get("two");
(numbers is the ht). I would like to key #1, and then key#2 etc. Simple put. Im want to get all my information out of my ht, but Im dont know how. Every code Ive found is depending on that your are aware of your keyname.


/ Sebastian<br />No blog, No homepage, No life?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

The Javadoc APIs are your friend. Have a look at the method keys(), which returns an Enumeration of all the keys in the Hashtable. Better (but more complicated and a bit harder for the novice to understand) is the entrySet() method, which returns a Set full of Map.Entry objects, each one of which contains a single key and a single value from the HashMap.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hashtable getting value without knowing the key
 
Similar Threads
better way?
criteriaFind
Threads access to object and performance/object in ServletContext: value or reference
Vector Vs. Hashtable
Hashtable vs. HashMap