Java examples for Collection Framework:Hashtable
Iterate through keys of Hashtable
import java.util.Hashtable; import java.util.Enumeration; public class Main { public static void main(String[] args) { /*w w w . j a v a 2 s . c o m*/ //create Hashtable object Hashtable ht = new Hashtable(); //add key value pairs to Hashtable ht.put("1","One"); ht.put("2","Two"); ht.put("3","Three"); Enumeration e = ht.keys(); //iterate through Hashtable keys Enumeration while(e.hasMoreElements()) System.out.println(e.nextElement()); } }