So I'm making a school database where you can enter a Student's information (Name, ID, Grade) through a class, but I just ran into a problem, how would I make a loop for someone to enter a student's id, name and grade? this is how the code looks if I were to write it before runtime (I will be using util.Scanner)
Student john = new Student(1, "John", 4)
It will then be added to an ArrayList
List<Student> studentsList = new ArrayList<>();
studentsList.add(john);
My problem is how will I name the variable be so it can be added to the list since there is no dynamic variables in java? This is a rough code of what I'm trying to do
for(int x = 0; x <= 10; x++){
int id, grade;
String name;
System.out.println("Name: ");
name = input.nextLine();
System.out.println("ID: ");
id = input.nextInt();
System.out.println("Grade: ");
grade = input.nextInt();
Student ??? = new Student(id, name, grade);
studentsList.add(???);
}