Solved

Hashtable get() method

Posted on 2004-09-01
1
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 19

Accepted Solution

by:
ramazanyich earned 125 total points
ID: 11957606
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

707 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