为什么还要定义一个对象temp呢?
public void Listadd(){ Course cr1=new Course("1","数据结构"); coursesToSelect.add(cr1); Course temp =(Course)coursesToSelect.get(0); System.out.println("添加了课程:"+temp.id+temp.name); Course cr2=new Course("2","C语言"); coursesToSelect.add(0,cr2); Course temp2 =(Course)coursesToSelect.get(0); System.out.println("添加了课程:"+temp2.id+temp2.name); }