Remove all values from Hashtable - Java Collection Framework

Java examples for Collection Framework:Hashtable

Description

Remove all values from Hashtable

Demo Code


import java.util.Hashtable;
 
public class Main {
 
  public static void main(String[] args) {
    Hashtable ht = new Hashtable();
   //from ww w  . ja  va  2  s  . c  o  m
    ht.put("1","One");
    ht.put("2","Two");
    ht.put("3","Three");
 
    ht.clear();
   
    System.out.println("Total key value pairs in Hashtable are : " + ht.size());
  }
}

Result


Related Tutorials