entrySet — сразу пара
for (Map.Entry<String, Integer> e : counts.entrySet()) {
System.out.println(e.getKey() + " = " + e.getValue());
}
Each Map.Entry is one key-value pair; getKey() and getValue() read it without another lookup. The type looks long, but the pattern is always the same.
Use keySet() when only the keys matter, and entrySet() when you need both.