package aaaa.imooc3;
import java.util.ArrayList;
import java.util.List;
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);
}
public static void main(String args){
ListTest lt = new ListTest();
lt.testAdd();
}
}
package aaaa.imooc3;
import java.util.HashSet;
import java.util.Set;
public class Student {
public String id;
public String name;
public Set courses;
public Student(String id,String name){
this.id = id;
this.name = name;
this.courses = new HashSet();
}
}
package aaaa.imooc3;
public class Course {
public String id;
public String name;
public Course(String id,String name){
this.id = id;
this.name = name;
}
}
主函数错了
public static void main(String[] args){ }