How to Iterate a Map in Java

Demo Program to Iterate a Map :

package com.mathapachi;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class HashTableDemo {
	public static void main(String[] args) {
		Map m = new HashMap();
		m.put("KEY1", 12233);
		m.put(736532, "London");
		m.put("KEY2", 343412233);
		Set entrySet = m.entrySet();
		Iterator iterator = entrySet.iterator();
		while (iterator.hasNext()) {
		    Entry entry = (Entry) iterator.next();
		    System.out.println("Key == " + entry.getKey() 
			       + " , Value == " + entry.getValue());
		}
	}
}

Output of the above Program is as below:

Key == KEY2 , Value == 343412233
Key == KEY1 , Value == 12233
Key == 736532 , Value == London