I created a user defined data type and read data from a file. Here are the codes:
Student Class:
package system.data;
public class Student {
private St
try moving Student student = new Student();
inside the for loop:
for (String item : strList) {
int x = 0;
String[] arr = item.split(":");
Student student = new Student();
student.setFirstName(arr[0]);
student.setLastName(arr[1]);
student.setRegNumber(arr[2]);
student.setCoursework1Marks(Integer.parseInt(arr[3]));
student.setCoursework2Marks(Integer.parseInt(arr[4]));
student.setFinalExamMarks(Integer.parseInt(arr[5]));
studentDetails.add(student);
}
hope this helps.