In this section of tutorial we will learn how to use the Hashtable with the Iterator interface. We will create an example to display the contents of the hashtable using Iterator
In this section of tutorial we will learn how to use the Hashtable with the Iterator interface. We will create an example to display the contents of the hashtable using Iterator
import java.util.*; public class hashtable { public static void main(String[] args) { Hashtable hastab = new Hashtable(); hastab.put("a", "andrews"); hastab.put("b", "bob"); hastab.put("c", "christina"); hastab.put("d", "dude"); hastab.put("e", "era"); Set s = hastab.entrySet(); Iterator it = s.iterator(); while (it.hasNext()) { System.out.println(it.next()); } } }
Output: