map相关操作:map遍历,map转换为list

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;
    }

  

posted @ 2015-07-13 15:55  vikey.z  阅读(1440)  评论(0编辑  收藏  举报