这两个遍历方法中后者循环中的c变量是不是每次循环都被定义一次,为什么不报错?
public void getcourse(){
int size = coursesToSelect.size();
Course c;
System.out.println("有如下课程:");
for(int i=0;i<size;i++){
c = (Course) coursesToSelect.get(i);
System.out.println(c.id+":"+c.name);
}
}
------------------------------------------------------
public void getcourse(){
int size = coursesToSelect.size();
System.out.println("有如下课程:");
for(int i=0;i<size;i++){
Course c = (Course) coursesToSelect.get(i);
System.out.println(c.id+":"+c.name);
}
}