首页 > 其他 > 详细

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

时间:2015-07-13 18:00:42      阅读:187      评论:0      收藏:0      [点我收藏+]
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;
    }

  

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

原文:http://www.cnblogs.com/codekey/p/4643130.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!