Answers for "iterate over a map"

4

go iterate over map

for k, v := range m { 
    fmt.Printf("key[%s] value[%s]\n", k, v)
}

// or

for k := range m {
    fmt.Printf("key[%s] value[%s]\n", k, m[k])
}
Posted by: Guest on April-10-2020
1

java iterate through map

for (Map.Entry<String, Object> entry : map.entrySet()) {
    String key = entry.getKey();
    Object value = entry.getValue();
    // ...
}
Posted by: Guest on May-25-2020
1

iterate map

Map<String, String> map = ...
for (Map.Entry<String, String> entry : map.entrySet()) {
    System.out.println(entry.getKey() + "/" + entry.getValue());
}
Posted by: Guest on May-19-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language