java for HashMap code example
Example 1: how to iterate hashmap in java
for (Map.Entry<String, String> entry : yourHashMap.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());
}
map.forEach((k, v) -> {
System.out.format("key: %s, value: %d%n", k, v);
});
Example 2: java loop hashmap
map.forEach((k, v) -> {
System.out.format("key: %s, value: %d%n", k, v);
});