为什么获取get[0]就正确,获取get[1]就下标越界,不是已经添加了一个吗,不就相当于有两个了吗
public List courSelect;
public ListTest(){
this.courSelect = new ArrayList();
}
public void testAdd(){
Course co = new Course("1","java");
courSelect.add(co);
Course senm = (Course) courSelect.get(0);
System.out.println(senm.id
+senm.name);
Course se = new Course("0","sql");
courSelect.add(0, se);
Course sen = (Course) courSelect.get(0);
System.out.println(sen.id+ " : " +sen.name);
}
public static void main(String[] args){
ListTest li = new ListTest();
li.testAdd();
}