//基于JDK1.8版本以上 lambada函数
map.forEach((k, v) -> { System.out.println("key:value = " + k + “:” + v); if (k.equals(“test”)) { //map.put(k, JsonUtil.fromJson((String) v, List.class)); } });
//keySet获取map集合key的集合 然后在遍历key即可
for(String key:map.keySet()){ String value = map.get(key).toString();// System.out.println(“key:”+key+" vlaue:"+value); }
//Map集合循环遍历方式三 推荐,尤其是容量大时
Iterator<Entry<String, Object>> it = map.entrySet().iterator(); while(it.hasNext()){ Entry<String, Object> entry = it.next(); System.out.println(“key:”+entry.getKey()+" key:"+entry.getValue()); }
// Map集合循环遍历方式三 强列推荐,尤其是容量大时
for (Map.Entry<String, Object> m : map.entrySet()) { System.out.println(“key:” + m.getKey() + " value:" + m.getValue()); }
//通过Map.values()遍历所有的value,但不能遍历key
for(Object m:map.values()){ System.out.println(m); }