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

Total Post:411

Points:2881
Posted on    May-07-2015 1:30 AM

 Java Java 
Ratings:


 1 Reply(s)
 461  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

Points:3117
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