Clears this hashtable so that it contains no keys.
Program
package com.candidjava;
import java.util.Hashtable;
import java.util.Properties;
/*
* @author : Mohan
* @description : The clear() method is used to clear this hashtable so that it contains no keys.
*/
public class PropertiesClear {
public static void main(String[] args) {
Properties properties = new Properties();
Hashtable ht = new Hashtable(properties);
ht.put("hai", "hari");
ht.put("good", "anand");
ht.put("code", "vinoth");
System.out.println(ht);
ht.clear();
System.out.println(ht);
// TODO Auto-generated method stub
}
}
Output
{hai=hari, code=vinoth, good=anand}
{}
Explanation
public void clear()
Clears this hashtable so that it contains no keys.