Core Java Tutorial

Core Java Tutorial

Hashtable Example program for clear()

[java]
/**
Author :candidjava.com
Description: Clears this hashtable so that it contains no keys.
*/
import java.util.*;
import java.util.Hashtable;
import java.io.IOException;
public class HashtableClearExample
{
public static void main(String args[])throws IOException
{
Hashtable h=new Hashtable();
h.put(1,11);
h.clear(); //it clears both the key and values which stores in hash table
System.out.println(h);
}
}

[/java]

Output:
{ }