Answers for "hashmap iterate all keys"

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
1

iterating over a hashmap

for(Map.Entry<String, Integer> entry : hashMap.entrySet()) {
    String key = entry.getKey();
    Integer value =  entry.getValue();
    //do something with the key and value
}
Posted by: Guest on November-19-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language