How can we iterate over the keys of myMap?

for (String k : myMap.keySet())for (String k : myMap)for (String k in myMap.get())while (String k = myMap.keySet())

Yup! In order to iterate over the keys of a HashMap, we can use a foreach loop and the keySet() method.

Yikes! In order to iterate over the keys of a HashMap, we can use a foreach loop and the keySet() method.