潜在的问题实际上是您应该将两个数组绑定在一起,并且仅跨一个数组进行迭代。
这是一个非常简单的演示-您应该使用getter和setter,还应该使用a
List而不是数组,但这证明了这一点:
class Student { String name; int mark;}Student[] students = new Student[10];for (Student s : students) { ...}
潜在的问题实际上是您应该将两个数组绑定在一起,并且仅跨一个数组进行迭代。
这是一个非常简单的演示-您应该使用getter和setter,还应该使用a
List而不是数组,但这证明了这一点:
class Student { String name; int mark;}Student[] students = new Student[10];for (Student s : students) { ...}