62,623
社区成员
发帖
与我相关
我的任务
分享class Student {
public String ID;
public String name;
public int score;
public Student() {
this.ID = "";
this.name = "";
this.score = 0;
}
public String toString() {
return ID + " " + name + " " + String.valueOf(score);
}
}
public class C {
public static int row;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
row = sc.nextInt();
LinkedList<Student> l = new LinkedList<Student>();
Student[] st = new Student[N+1] ;
for (int i = 0; i < N; i++) {
System.out.println(st[i]);//为什么都输出null呢?而不是 0呢?(0前面是2个空格)
}
}
class Student {
public String ID;
public String name;
public int score;
public Student() {
this.ID = "";
this.name = "";
this.score = 0;
}
public String toString() {
return ID + " " + name + " " + String.valueOf(score);
}
}
public class Test {
public static int row;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
row = sc.nextInt();
//LinkedList<Student> l = new LinkedList<Student>();
Student[] st = new Student[N + 1]; //仅仅起到声明作用。
for (int i = 0; i < N; i++) {
st[i] = new Student(); //需要初始化;
System.out.println(st[i]);
}
}