Get both key and value from Hashtable element.
Posted on 2002-05-07
I've got a Hashtable storing parameter data in a class I'm using for message passing. The key values used to index the hashtable will vary from instance to instance, as different messages will use different parameters (think of it like xml if that helps: <tag key="value" key="value">, where both the keys and values vary from tag to tag).
I need to iterate over the hashtable, extracting both the value *and* the key of each element contained therein.
The generic Iterator's next() method returns an object, which in the case of Hashtable I presume is the value section of the particlar element. The Object class contains a method int hashCode(), which seems to be something near what I'm after, except that an integer isn't of much use to me -- I need something I can extract a String key from.
How can I do this?