Basically, using sets and lists we can iterate for the key or values or the whole key/value entity. Also, you can use the below code as well:
Map<K,V> m=new LinkedHashMap<K,V>();
for(Map.Entry<K,V> entry: m.entrySet())
System.out.println(entry.getKey() + ": " + entry.getValue());
I hope this will help.
Want to know more about Java? Prefer this tutorial on Learn Java.
Want to become a Java Expert? Join Java Certification now!!