class StudentList{ protected static ArrayList<Student> studentList = new ArrayList<>(); public StudentList(String path) throws FileNotFoundException { Scanner scanner = new Scanner(new File(path)); int count = Integer.parseInt(scanner.nextLine()); for(int i = 0; i < count; i++){ studentList.add(new Student(scanner.nextLine(), scanner.nextLine(), scanner.nextLine(), scanner.nextLine() ) ); } } public String toString() { StringBuilder stringBuilder = new StringBuilder(); for(Student student : studentList){ stringBuilder.append(student).append("\n"); } return stringBuilder.toString(); } }