package student_system_new;
public class Student {
public Student() {
this.studentID = 0;
this.Name = "";
Math = 0.0;
Chinese = 0.0;
English = 0.0;
}
public Student(int studentID, String name, double math, double chinese, double english) {
this.studentID = studentID;
this.Name = name;
Math = math;
Chinese = chinese;
English = english;
}
private int studentID;
private String Name;
private double Math;
private double Chinese;
private double English;
public void setName(String name) {
Name = name;
}
public void setStudentID(int ID) {
studentID = ID;
}
public void setMath(double math) {
Math = math;
}
public void setChinese(double chinese) {
Chinese = chinese;
}
public void setEnglish(double english) {
English = english;
}
}
package student_system_new;
import java.util.*;
public class Classes {
public Classes() {
super();
}
final static int SIZE = 5;
private Student[] class1 = new Student[SIZE];
public void setData() {
System.out.println("输入学生数据:学号、姓名、数学、语文、英语");
Scanner data = new Scanner(System.in);
for(Student a: class1) {
a.setStudentID(data.nextInt());
a.setName(data.next());
a.setMath(data.nextDouble());
a.setChinese(data.nextDouble());
a.setEnglish(data.nextDouble());
}
data.close();
}
}
package student_system_new;
public class Texter {
public static void main(String[] args) {
// TODO Auto-generated method stub
Classes first = new Classes();
first.setData();
}
}
有三个类,setData目的是想输入五个学生数据,可是在输入的时候显示了一个错误。这个错误好像是跟数组有关,可是我弄了好久没搞清楚,哪位大神能帮一下....