我都是输出了地址,怎么才能输出值呢?
System.out.println("通过foreach访问元素");
for(Object obj:courseToSelect){
Course cr = (Course)obj;
System.out.println(" 已有课程: " +cr.getId()+" : "+cr.getName());
}
有用,谢谢
public void testForEach(){
for(Object obj:coursesToSelect){
Course cr=(Course) obj;
System.out.println("课程:"+cr.id+":"+cr.name);
}
}