You can use the following different ways..... 1: Iterating HashMaps over entries using For-Each loop. Use this if you need both map keys and values in the loop. Map<String, String> map = new HashMap<String, String>(); for (Map.Entry<String, String> entry : map.entrySet()) { System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); } ------------------------------------------------------------------- 2. Filterating over keys or values using for-each loop....... If you need only keys or values from the map, you can iterate over keySet or values instead of entrySet. Map<Integer, Integer> map = new HashMap<Integer, Integer>(); //iterating over keys only for (Integer key : map.keySet()) { System.out.println("Key = " + key); } //iterating over values only for (Integer value : map.values()) { System.out.println("Value = " + value); } -------------------------------------------------...