ArrayList的大小不是可以按照需要动态增长的吗?为什么添加课程id=4的时候会报IndexOutOfBoundsException
Course temp2=(Course)coursesToSelect.get(0);
System.out.println("添加了课程:"+temp2.getId()+":"+temp2.getName());
Course cr3=new Course("3","test");
coursesToSelect.add(4,cr3);
Course temp2=(Course)coursesToSelect.get(0);
System.out.println("添加了课程:"+temp2.getId()+":"+temp2.getName());
Course cr3=new Course("3","test");
coursesToSelect.add(4,cr3);
2016-03-23
举报