Check out example codes for "java for map". It will help you in understanding the concepts better.

Code Example 1

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

for(Entry<String, String> entry:map.entrySet()) {
  System.out.println("key: "+entry.getKey()+" value: "+entry.getValue());

Code Example 2

// Java program to demonstrate iteration over  
// Map using keySet() and values() methods 
import java.util.Map; 
import java.util.HashMap; 
class IterationDemo  
    public static void main(String[] arg) 
        Map<String,String> gfg = new HashMap<String,String>(); 
        // enter name/url pair 
        gfg.put("GFG", ""); 
        gfg.put("Practice", ""); 
        gfg.put("Code", ""); 
        gfg.put("Quiz", ""); 
        // using keySet() for iteration over keys 
        for (String name : gfg.keySet())  
            System.out.println("key: " + name); 
        // using values() for iteration over keys 
        for (String url : gfg.values())  
            System.out.println("value: " + url); 

Code Example 3

//traditional way (long)
for(map<string,int>::iterator it=m.begin(); it!=m.end(); ++it)
	if(it->second)cout<<it->first<<" ";
//easy way(short) just works with c++11 or later versions
for(auto &x:m)
	if(x.second)cout<<x.first<<" ";
//condition is just an example of use

Learn ReactJs, React Native from