首页 > 其他 > 详细

invertMap

时间:2014-02-27 05:41:00      阅读:458      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
 1 /**
 2      * 转换Map表中的key和value
 3      * @param <V> key的类型
 4      * @param <K> value的类型
 5      * @param map 转换前的map
 6      * @return 转换后的map
 7      */
 8     public static <V, K> Map<V, K> invertMap(Map<K, V> map)
 9     {
10         Map<V, K> out = new HashMap<V, K>(map.size());
11         for (Iterator<Map.Entry<K, V>> it = map.entrySet().iterator(); it
12                 .hasNext();)
13         {
14             Map.Entry<K, V> entry = (Map.Entry<K, V>) it.next();
15             out.put(entry.getValue(), entry.getKey());
16         }
17         return out;
18     }
bubuko.com,布布扣

invertMap,布布扣,bubuko.com

invertMap

原文:http://www.cnblogs.com/xzs603/p/3568843.html

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