魔兽传奇

java程序爱好者
posts - 28, comments - 16, trackbacks - 0, articles - 6
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

去除List中的重复数据

Posted on 2008-03-05 19:12 龙旋风 阅读(541) 评论(0)  编辑  收藏
  List templist= new ArrayList();//要去除重复的list
 List otherlist = new ArrayList();
 for(int j =0;j<templist.size();j++){
     Object object =(Object)templist.get(j);
     if(object!=null){
       otherlist.add(object);
       templist.set(j,null);
       for(int k= 0;k<templist.size();k++){
           if(j!=k){
              Object object1 = (Object)templist.get(k);
              if(object1!=null){
                if(StringUntil.isEquals(object,object1){ templist.set(k,null);}
            }
       }
    }
}

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


网站导航: