使用泛型后,怎么添加数组
public class ListTest {
public List<Course> courseToSelect;
public ListTest()
{
this.courseToSelect=new ArrayList<Course>();
}
public void addTest()
{
Course[] cr1={new Course("2","化学"),new Course("1","数学")};
courseToSelect.addAll(cr1);
}
public void forEach()
{
for(Course cou:courseToSelect)
{
System.out.println("课程"+cou.id+":"+cou.name);
}
}
public static void main(String[] args)
{
ListTest it=new ListTest();
it.addTest();
it.forEach();
}
}