How do I iterate over each Entry in a Java Map?

I have implemented the Map interface on an object in Java and I need to know the most efficient way of iterating through the map.


  • for (Map.Entry<String, String> entry : map.entrySet())
        // You can get the values of entry.getKey() and entry.getValue()) to do any process.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion