for each hashmap java code example
Example 1: how to iterate hashmap java
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
Example 2: foreach hashmap java
hashmap.forEach(BiConsumer<K, V> action)