In this tutorial we will see how to use the Java Map iterator interface with ArrayList. We will create an example to display the contents of the ArrayList.
In this tutorial we will see how to use the Java Map iterator interface with ArrayList. We will create an example to display the contents of the ArrayList.
import java.util.*; public class map { public static void main(String[] args) { Map map = new TreeMap(); map.put("a", new Integer(1000)); map.put("b", 2000); map.put("c", new Integer(3000)); map.put("d", new Integer(4000)); Set s = map.entrySet(); Iterator i = s.iterator(); while (i.hasNext()) { System.out.println(i.next()); } } }
Output
a=1000 b=2000 c=3000 d=4000