Home > DeveloperSection > Forums > Iterate over each Entry in a Map
Pravesh Singh

Total Post:411

Posted on    May-07-2015 1:30 AM

 Java Java 

 1 Reply(s)
 482  View(s)
Rate this:

If I have an object implementing the MAP interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map?

Will the ordering of elements depend on the specific map implementation that I have for the interface?

Mayank Tripathi
Mayank Tripathi

Total Post:397

Posted on    May-07-2015 7:21 AM

for (Map.Entry<String, String> entry : map.entrySet())
    System.out.println(entry.getKey() + "/" + entry.getValue());

Don't want to miss updates? Please click the below button!

Follow MindStick