Solved

Hashtable get() method

Posted on 2004-09-01
1
293 Views
Last Modified: 2010-03-31
Ok so this is a really easy question but I just havent used hashtables before.  I have been looking at documentation and I am alittle confused.  I have a bunch of data stored in a hashtable.  Now I want to go through that data element by element and get it out of the hashtable.  I know that I have to use the hashtable get() method however I am not really sure how to do this because the part with the keys kind of confuses me.  I was trying to go through it simply like an array but it did not work.  Can someone kind of give me a hand on how to go through the hashtable with keys?  


Thanks!
0
Comment
Question by:kassidy2010
1 Comment
 
LVL 19

Accepted Solution

by:
ramazanyich earned 125 total points
Comment Utility
Hashtable h = new Hashtable();
h.put("key","value");
// other h.put() calls;
Enumeration enum = h.keys();
while(enum.hasMoreElements()){
 Object key = enum.nextElement();
 Object value = h.get(key);
 System.out.println(key+":"+value);
}
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now