hi I'm working on my hw and I have problem
I know how to read file from data and split each line using array
now I want to use arrayList .. I want to read the data from the file and create arrayList and then split each line and create object of type student
the file contanin id,program,gpa
I have Student class and the main form
in the student class I have format method , get and set methods
and this constructor
public Student(int id, String program, double gpa) {
this.id = id;
this.program = program;
this.gpa = gpa;
}
//this is my main form
package hw;
import java.util.ArrayList;
import java.util.List;
import utilities.FileUtils;
public class JFrameHw extends javax.swing.JFrame {
List<Student> student = new ArrayList();
public JFrameHw() {
initComponents();
student = createStudent(txtFile.getText());
}
// This is my method
public List<Student> createStudent(String fileName) {
String[] data = FileUtils.readIntoArray(fileName);
List<Student> res = new ArrayList();
for (int i = 0; i < student.size(); i++) {
Student line = student.get(i);
//Student line = (Student) list;
}
return res;
}