Snippets: Java: Map

20th August 2020 at 2:19pm
Snippets: Java

Iterating

Map<String, Object> map = ...;

// iterate keys
for (String key : map.keySet()) {
    // ...
}

// iterate values
for (Object value : map.values()) {
    // ...
}

// iterate key-values
for (Map.Entry<String, Object> entry : map.entrySet()) {
    String key = entry.getKey();
    Object value = entry.getValue();
    // ...
}