![]() |
VOOZH | about |
The elements() method in the Hashtable class in Java returns an enumeration of the values contained in the hashtable. The enumeration returned by this method traverses the hashtable's values in the order in which they were added to the hashtable.
The elements() method is inherited from the java.util.Hashtable class's parent class, java.util.Dictionary.
30 35 25
The java.util.Hashtable.elements() method of the Hashtable class in Java is used to get the enumeration of the values present in the hashtable.
Syntax:
Enumeration enu = Hash_table.elements()
Parameters: The method does not take any parameters.
Return value: The method returns an enumeration of the values of the Hashtable.
Below programs are used to illustrate the working of the java.util.Hashtable.elements() method:
Program 1:
Output:
The Table is: {10=Geeks, 20=Geeks, 30=You, 15=4, 25=Welcomes}
The enumeration of values are:
Geeks
Geeks
You
4
Welcomes
Program 2:
Output:
The Table is: {You=30, Welcomes=25, 4=15, Geeks=20}
The enumeration of values are:
30
25
15
20