foreach loop java values hashmap
public static void printMap(Map mp) {
Iterator it = mp.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
System.out.println(pair.getKey() + " = " + pair.getValue());
it.remove(); // avoids a ConcurrentModificationException
}
}
4.17
6
hashmap.forEach(BiConsumer<K, V> action)
Thank you!
6
0
3.67
9
for (V valuesName : arbitraryHashMap.values()) {
//Do Stuff with valuesName
}
Thank you!
9
0
Are there any code examples left?
New code examples in category Java