Remove value from Hashtable - Java Collection Framework

Java examples for Collection Framework:Hashtable

Description

Remove value from Hashtable

Demo Code


import java.util.Enumeration;
import java.util.Hashtable;
 
public class Main {
 
  public static void main(String[] args) {
    Hashtable ht = new Hashtable();
   //from   ww  w. j a v  a 2s.c o  m
    //add key value pairs to Hashtable
    ht.put("1","One");
    ht.put("2","Two");
    ht.put("3","Three");
 
    Object obj = ht.remove("2");
    System.out.println(obj + " Removed from Hashtable");
   
    //print remaining Hashtable values
    Enumeration e = ht.elements();
   
    //iterate through Hashtable values Enumeration
    while(e.hasMoreElements())
      System.out.println(e.nextElement());
  }
}
 

Result


Related Tutorials