Mega Code Archive

 
Categories / Java / Collections Data Structure
 

Remove value from Java Hashtable

import java.util.Enumeration; import java.util.Hashtable; public class Main {   public static void main(String[] args) {     Hashtable<String, String> ht = new Hashtable<String, String>();     ht.put("1", "One");     ht.put("2", "Two");     ht.put("3", "Three");     Object obj = ht.remove("2");     System.out.println(obj + " was Removed ");     Enumeration e = ht.elements();     while (e.hasMoreElements()){       System.out.println(e.nextElement());     }   } }