I want to make turn this program's array into an ArrayList. So far I know that the array will turn into
ArrayList<StudentList> list = new ArrayList<StudentList>();
and that each list[i] will turn into:
list.get(i)
however I am not sure what the following line will be in order to satisfy the ArrayList version
list[i] = new StudentList();
so here is the full code:
public static void main(String[] args) {
StudentList[] list = new StudentList[5];
int i;
for (i = 0; i < list.length; ++i) {
list[i] = new StudentList();
System.out.println("\nEnter information of Student _" + (i + 1) + "\n");
list[i].DataUserPrompt();
}
for (i = 0; i < list.length; ++i) {
list[i].DisplayStudentData();
}
File file12 = new File("s_records.txt");
try {
PrintWriter output = new PrintWriter(file12);
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}