解决方案 »

  1.   

    不可以在遍历ArrayList的时候还调用list的方法对其进行增删
      

  2.   

    集合的循环就是循环,不要在循环的同时去做增删操作另外要根据关键子判断是否同一个对象,优先考虑下用Map来存储将Map的key设置成你的关键字,值是你的对象,这样判断方便
      

  3.   

    Google this Exception,IF you find a lot of people talking it, just find how to fix it.
    If not, your program must be wrong.
      

  4.   

    package cn.com.mytest.test;import java.util.ArrayList;
    import java.util.List;import com.mytest.po.student.Student;public class Test1 {
    public static void main(String[] args) {
     List<Student> personDisList = new ArrayList<Student>();
     Student person1 = new Student();
     person1.setId(1);
     person1.setName("test1");
     person1.setClassName("sfs");
     person1.setAge(12);
     Student person2 = new Student();
     person2.setId(2);
     person2.setName("test2");
     person2.setClassName("231s");
     person2.setAge(11);
     personDisList.add(person1);
     personDisList.add(person2);  List<Student> personList = new ArrayList<Student>();
     for (int i=0; i<personDisList.size(); i++){
     Student person=new Student();
         person.setId(personDisList.get(i).getId());
         if(personList.size()!=0){
          boolean bn=false;
     for (int j=0;j<personList.size();j++) {
    if(personDisList.get(i).getId()!=personList.get(j).getId());{
    personList.add(personDisList.get(i));
    break;
    }
    }
         }else{
          personList.add(person);
         }
         System.out.println(personList.size());
      }
     }
     
    }楼主看看这是不是你要的代码;