Iterating through a map in Java

posted by Ted on

I've always wanted to know the best way to iterate over the elements in a map. Here's one way I've found that works.

for (Map.Entry<key,value> entry : map.entrySet()) {
    entry.getKey().doSomethingWithThisEntryValue(entry.getValue());
}

Leave a comment

blog comments powered by Disqus