首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

list剔除元素的方法

2012-11-09 
list删除元素的方法public void setReparation( Reparation reparation ) {boolean flag falsefor (Ite

list删除元素的方法

public void setReparation( Reparation reparation ) {       boolean flag = false;       for (Iterator it = this.reparations.iterator();it.hasNext();){    //reparations为Collection           Reparation repa = (Reparation)it.next();           if (repa.getId() == reparation.getId()){               it.remove();               flag = true;               break;           }       }       if(flag){         this.reparations.add(reparation);       }   }  

?

热点排行