Cycle map (rpm)

The new features of the JDK For loop with Map, e.g. Key Map of cycle

for(String dataKey : paraMap.keySet()) 
{ 
System.out.println(dataKey ); 
}



It should be noted here that, paraMap is how to define, if it is a simple Map paraMap = new HashMap (); it can only be replaced in front of the String Object a.

The whole Map of the key and value are cyclically as follows:



for(Map.Entry<String, Object> entry : paraMap.entrySet()) 
{ 
System.out.println(entry.getKey()+": "+entry.getValue()); 
}



If in the past, it is such a loop:

Iterator it = paraMap.entrySet().iterator(); 
while (it.hasNext()) 
{ 
Map.Entry pairs = (Map.Entry)it.next(); 
System.out.println(pairs.getKey() + " = " + pairs.getValue()); 
}

Reproduced in: https: //my.oschina.net/dddgggaaa/blog/204926

Guess you like

Origin blog.csdn.net/weixin_33893473/article/details/92046887
rpm
map
Map
Map
map