保存到特定数组列表(java)

保存到特定数组列表(java),java,arrays,arraylist,java.util.scanner,Java,Arrays,Arraylist,Java.util.scanner,我正在尝试做一个项目,在这个项目中,我将学生名单保存到他们想要的课程中。我知道如何使用数组列表将学生保存到一个列表中并再次调用他们,但我想知道是否可以将他们保存到特定的数组列表中。例如,如果可能的话 n = //n gets its name (Comp 182 or Comp 101 from a file which is read) //using java-util scanner to read a file which will have the course name there.

我正在尝试做一个项目,在这个项目中,我将学生名单保存到他们想要的课程中。我知道如何使用数组列表将学生保存到一个列表中并再次调用他们,但我想知道是否可以将他们保存到特定的数组列表中。例如,如果可能的话

n = //n gets its name (Comp 182 or Comp 101 from a file which is read)
//using java-util scanner to read a file which will have the course name there.

ArrayList<n> CourseList = new ArrayList<n>();
n=//n获取其名称(Comp 182或Comp 101来自读取的文件)
//使用java util scanner读取一个文件,其中包含课程名称。
ArrayList CourseList=新的ArrayList();

要创建多个列表以便将它们放入正确的列表中,还是有其他方法?

假设您有一个学生班级,那么您可以在一个列表中保存多个记录。您需要定义一个列表,如

List<Student> students = new ArrayList<Student>();

如果您试图将任何其他对象添加到此列表中,则会出现编译时错误。

是否为
n
类?你的程序的其余部分的结构是什么?
students.add(new Student(...));