In Java there are many ways to iterate the Hash Map. We need to consider the way it has good performance and less number of looks up in the Map. Generally we do like get the list of keys using keyset() and get the values of each element in the map by using map.getValue by passing the key. This works for sure but this is not best way. Good way would by using Map.Entry interface in java

for ( Map.Entry<String, Integer> entry : map.entrySet() ) {
    String k = entry.getKey();
    Integer v = entry.getValue();
}
In the above example in singe lookup we can get both key and values. This could be of the good way to iterate HashMap.