![]() |
VOOZH | about |
The java.util.Hashtable.size() method of Hashtable class is used to get the size of the table which refers to the number of the key-value pair or mappings in the Table.
Syntax:
Hash_Table.size()
Parameters: The method does not take any parameters.
Return Value: The method returns the size of the table which also means the number of key-value pairs present in the table. Below programs illustrates the working of java.util.Hashtable.size():
Program 1:
Initial table is: {10=Geeks, 20=Geeks, 30=You, 15=4, 25=Welcomes}
The size of the table is 5Program 2:
Initial Table is: {You=30, Welcomes=25, 4=15, Geeks=20}
The size of the table is 4Note: The same operation can be performed with any type of variation and combination of different data types.