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

Hashtable getting value without knowing the key

 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic