Use keySet() to iterate over keys in a HashMap, and get(key) to retrieve the value associated with a key.
Source Code
HashMap capitalCities = new HashMap();
capitalCities.put("England", "London");
capitalCities.put("Germany", "Berlin");
for (String key : capitalCities.keySet()) {
System.out.println("Key: " + key + ", Value: " + capitalCities.get(key));
}