征服

小杨之家

删除map中指定的value

   Map中删除指定的键值对
   Map map = new HashMap();
   map.put(
11);
   map.put(
22);
   map.put(
34);
  //拿出map中的键值对
   Set entries 
= map.entrySet();
   for (Iterator iterator = entries.iterator();  iterator.hasNext();) {
        Map.Entry entry 
= (Map.Entry) iterator.next();
       
int i = (Integer) entry.getValue();
        
if (i == 2) {
   //就是调用
iterator.remove()方法可以移除掉map中键值对
        iterator.remove();
        }
   }

posted on 2009-06-23 09:41 杨英杰 阅读(1527) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 
<2009年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

导航

统计

常用链接

留言簿

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜