Remove Value From Java HashTable
Chapter:
Collections
Last Updated:
15-05-2016 16:09:46 UTC
Program:
/* ............... START ............... */
import java.util.Enumeration;
import java.util.Hashtable;
public class JavaHashTableRemoveValue {
public static void main(String[] args) {
Hashtable hashTable = new Hashtable();
hashTable.put("1", "One");
hashTable.put("2", "Two");
hashTable.put("3", "Three");
Object obj = hashTable.remove("2");
System.out.println(obj + " Removed from Hashtable");
Enumeration enumeration = hashTable.elements();
// iterate through Hashtable values Enumeration
while (enumeration.hasMoreElements())
System.out.println(enumeration.nextElement());
}
}
/* ............... END ............... */
Output
Two Removed from Hashtable
Three
One
Tags
Collection, Remove All Elements From Java HashTable, Java