having issues with my output while trying to create an array file
import java.io.*;
import java.util.ArrayList;
public class MainClass
{
public static void main(String[] args)throws FileNotFoundException, IOException
{
File myfile = new File("students.txt");
ArrayList<Student> studentList = new ArrayList<Student>();
studentList.add(new Student("Gondi", 68));
studentList.add(new Student("George", 52));
studentList.add(new Student("Aaron", 25));
studentList.add(new Student("Gavin", 36));
studentList.add(new Student("joe", 42));
FileOutputStream fo = new FileOutputStream(myfile);
ObjectOutputStream output = new ObjectOutputStream(fo);
for (Student s : studentList)
{
output.writeObject(s);
}
fo.close();
output.close();
}
}
import java.io.Serializable;
public class Student implements Serializable {
public String StudentName;
public int StudentAge;
public Student(String name, int age) { S
tudentName = name; StudentAge = age;
}
}