Depends. If you know you're going to need both the key and the value of every entry, then go through the entrySet
. If you just need the values, then there's the values()
method. And if you just need the keys, then use keyset()
.
A bad practice would be to iterate through all of the keys, and then within the loop, always do map.get(key)
to get the value. If you're doing that, then the first option I wrote is for you.