import java.util.*;
public class TestGeneric {
public List<Course> courses;
public void TestGeneric(){
courses=new ArrayList<Course>();
}
public void testAdd(){
Course c1=new Course("1","课程1");
courses.add(c1);
Course c2=new Course("2","课程2");
courses.add(c2);
}
courses.add(c1);为什么这行总报错
构造函数不能有返回值『void』,,,这种报错是你调用了空指针,原因是你courses的构造函数有错导致没有实例化成功