Java HashSet Iterate Through Value
Chapter:
Collections
Last Updated:
15-05-2016 16:05:33 UTC
Program:
/* ............... START ............... */
import java.util.Hashtable;
import java.util.Enumeration;
public class JavaHashTableIterationThroughValue {
public static void main(String[] args) {
Hashtable hashTable = new Hashtable();
// add key value pairs to Hashtable
hashTable.put("1", "One");
hashTable.put("2", "Two");
hashTable.put("3", "Three");
/*
* get Enumeration of values contained in Hashtable using Enumeration
* elements() method of Hashtable class
*/
Enumeration enumeration = hashTable.elements();
// iterate through Hashtable values Enumeration
while (enumeration.hasMoreElements())
System.out.println(enumeration.nextElement());
}
}
/* ............... END ............... */
Output
Tags
Collection, HashSet Iterate Through, Java