Answers for "loop on a map java"

5

java for map

Map<String, String> map = new HashMap<>();

for(Entry<String, String> entry:map.entrySet()) {
  System.out.println("key: "+entry.getKey()+" value: "+entry.getValue());
}
Posted by: Guest on July-07-2020
3

java foreach map

map.forEach((k, v) -> System.out.printf( " %s : %d \n" , k,v) );
Posted by: Guest on March-16-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language