public static void retunKeyAndValue(Map<String,Object> map){ System.out.println("通过Map.entrySet遍历key和value"); for (Map.Entry<String, Object> entry : map.entrySet()) { System.out.println("key = " + entry.getKey() + " and value = " + entry.getValue()); } } /** * map 转换成list */ public static List returnList(Map map) { List list = new ArrayList(); Iterator iter = map.entrySet().iterator(); //获得map的Iterator while(iter.hasNext()) { Entry entry = (Entry)iter.next(); list.add(entry.getValue()); } return list; }
时间: 2024-10-19 11:38:09