我正在尝试创建一个数组来收集学生,并为每个学生创建一个成绩数组。我的 int 计数将随着 while 循环或其他内容而增加。问题是我的学生数组出现错误。有其他方法吗?
static int count = 0;
static int[] Grades = new int[count];
static String[] Students = new String[Grades[count];
最佳答案
您可以创建一个包含姓名、年龄等和成绩数组/列表的 Student 类:
class Student {
String name;
String age;
//...
List<Integer> grades;
//Getters & Setters of course
}
您可以添加一个方法来获取 {name:grades} 的 map
关于java - 如何拥有一个由数组 : Java? 索引的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14923762/