package com.imooc.cellection;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
public class ListTest {
public List coursesToSelect;
public ListTest(){
this.coursesToSelect = new ArrayList();
}
public void testAdd(){
Course cr1 = new Course("1","数据结构");
coursesToSelect.add(cr1);
Course temp = (Course)coursesToSelect.get(0);
System.out.println("添加了课程:"+temp.id+":"+temp.name);
为了验证数据确实传进 了coursesToSelect
你添加之后是第一个数据吗?coursesToSelect.get(0);这是获取的第一个数据