![]() |
VOOZH | about |
The java.util.Hashtable.clear() method in Java is used to clear and remove all of the keys from a specified Hashtable.
Syntax:
Hash_table.clear()
Parameters: The method does not accept any parameters.
Return Value: The method does not return any value. Below programs are used to illustrate the working of java.util.Hashtable.clear() Method:
Program 1:
The Hashtable is: {10=Geeks, 20=Geeks, 30=You, 15=4, 25=Welcomes}
Finally the table looks like this: {}Program 2:
The Hashtable is: {You=30, Welcomes=25, 4=15, Geeks=20}
Finally the table looks like this: {}Note: The same operation can be performed with any type of variation and combination of different data types.