Explanation: As the class implements the Map interface the set-view of the Hashtable can be obtained
using the entrySet method of the Map interface. Once obtained, then using iterator and MapEntry
interface all the keys and values of the Hashtable can be displayed. One more method using the keySet
method and iterator is given as:
Iterator itr;
System.out.println(“\nKEYS\tVALUES”);
Set S = HT.entrySet();
for (itr = S.iterator(); itr.hasNext(); )
{
Object obj = itr.next();
System.out.println(obj+ “\t”+HT.get(obj));
}
Here using the keySet method a set of keys is obtained, and using Iterator ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.