for(String dataKey : paraMap.keySet()) { System.out.println(dataKey ); }这里要注意的是,paraMap是怎么样定义的,如果是简单的Map paraMap = new HashMap();那前面的String就只能换成Object了. 对整Map的key和value都进行循环,如下:
for(Map.Entry要是在以前,则是这么循环的:entry : paraMap.entrySet()) { System.out.println(entry.getKey()+": "+entry.getValue()); }
Iterator it = paraMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); System.out.println(pairs.getKey() + " = " + pairs.getValue()); }