Whenever you iterate a map and you need to access both the key and its value it's best to iterate over the entry set.