Note how to loop Map in Java
Map<String, String> map = new HashMap<>();
//map key,value set processing is omitted
//for Each pattern
map.forEach((k, v) -> {
System.out.println(k);
System.out.println(v);
});
//Extended for statement pattern
for(Map.Entry<String, String> entry : map.entrySet()){
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}
ForEach may be cleaner and easier to see.
Recommended Posts