空指针异常啊
import java.util.ArrayList;
import java.util.List;
public class ListTest {
public List courseToSelect;
public ListTest() {
List courseToSelect = new ArrayList();
}
public void testAdd() {
//往courseToSelect添加课程;
Course cr1 = new Course("1","数据结构");
courseToSelect.add(cr1);
Course temp = (Course)courseToSelect.get(0);
System.out.println("添加了一门课程:"+temp.id+":"+temp.name);
}
public static void main(String[] args) {
ListTest lt = new ListTest();
lt.testAdd();
}
}