how iterate map in java code example
Example 1: java foreach map
map.forEach((k, v) -> System.out.printf( " %s : %d \n" , k,v) );
Example 2: iterate through map
//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