为什么用了get和set方法返回值为空啊?(添加了课程:null:null 添加了课程:null:null)
public class Course {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Course(String id, String name) {
// TODO Auto-generated constructor stub
}
}
Course cr1=new Course("1","数据结构");
coursesToSelect.add(cr1);
Course temp=(Course) coursesToSelect.get(0);
System.out.println("添加了课程:"+temp.getId() +":"+temp.getName() );
Course cr2=new Course("2","C语言");
coursesToSelect.add(0,cr2);
Course temp1=(Course) coursesToSelect.get(0);
System.out.println("添加了课程:"+temp1.getId() +":"+temp1.getName() );