title: new objects do not appear in javafx
body: <p>I have an arraylist of students and I am writing it to a text file in my save method and this is successful every time i run the application and it loads all of my objects the first time i run the program successfully. My problem is when I start the app again after closing and try to save and load new objects then it only loads my old objects from the first session and not any of the new saved objects.Save method is to write and load method is to read</p>
  <pre><code>package application;
  import java.io.Serializable;
  public class Student implements Serializable{
      
      
      private String name = null;     //students name
      private int ID = 0;             //students ID number
      private String DOB = null;      //Students Date of Birth
      
      
      public Student(String name,int ID, String DOB) {
          this.setName(name);
          this.setID(ID);
          this.setDOB(DOB);
      }
      
      public void printStudent() {
          System.out.println(&quot;Name: &quot; + name + &quot; ID: &quot; + ID + &quot; DOB: &quot; + DOB);
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public int getID() {
          return ID;
      }
      public void setID(int iD) {
          ID = iD;
      }
      public String getDOB() {
          return DOB;
      }
      public void setDOB(String dOB) {
          DOB = dOB;
      }
      @Override public String toString() {
          return &quot;Name: &quot; + name + &quot;    | ID:  &quot; + ID  + &quot;    | Date of birth:  &quot; + DOB;
      }
  }
  </code></pre>
  <hr />
  <pre><code>package application;
      
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.PrintWriter;
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.StringJoiner;
  import javafx.application.Application;
  import javafx.geometry.Insets;
  import javafx.geometry.Pos;
  import javafx.stage.Stage;
  import javafx.scene.Scene;
  import javafx.scene.control.Alert;
  import javafx.scene.control.Alert.AlertType;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.control.TableView;
  import javafx.scene.control.TextArea;
  import javafx.scene.control.TextField;
  import javafx.scene.control.cell.PropertyValueFactory;
  import javafx.scene.layout.BorderPane;
  import javafx.scene.layout.HBox;
  import javafx.scene.layout.VBox;
  public class Test extends Application {
      
      
        ArrayList&lt;Student&gt; arraylist = new ArrayList&lt;Student&gt;();          //arraylist of student objects
        Student student;
        
        Student line;
        Validation validation = new Validation();
        
       
      
      @Override
      public void start(Stage primaryStage) {
          try {
          
              primaryStage.setTitle(&quot;MTU Student record system&quot;);
              
              
              
              Label enterNamelbl = new Label(&quot;Enter Student Name&quot;);
              TextField enterNametxt = new TextField();
              HBox hbox1 = new HBox(42,enterNamelbl,enterNametxt);
             
              hbox1.setAlignment(Pos.CENTER);
              
              Label enterIDlbl = new Label(&quot;Enter Student ID&quot;);
              TextField enterIDtxt = new TextField();
              HBox hbox2 = new HBox(70,enterIDlbl,enterIDtxt);
              hbox2.setAlignment(Pos.CENTER);
              
              Label enterDOBlbl = new Label(&quot;Enter Student Date of Birth&quot;);
              TextField enterDOBtxt = new TextField();
              HBox hbox3 = new HBox(27,enterDOBlbl,enterDOBtxt);
              hbox3.setAlignment(Pos.CENTER);
              
              Button addbtn = new Button(&quot;Add&quot;);
              Button removebtn = new Button(&quot;Remove&quot;);
              Button listbtn = new Button(&quot;List&quot;);
              HBox hbox4 = new HBox(12,addbtn,removebtn,listbtn);
              hbox4.setAlignment(Pos.CENTER);
              
              
              TextArea textArea = new TextArea();
              HBox hbox5 = new HBox(textArea);
              
              
             
              Button load = new Button(&quot;Load&quot;);
              Button save = new Button(&quot;Save&quot;);
              Button exit = new Button(&quot;Exit&quot;);
              HBox hbox6 = new HBox(12,load,save,exit);
              hbox6.setAlignment(Pos.BOTTOM_RIGHT);
              
             
              VBox vbox1 = new VBox(29,hbox1,hbox2,hbox3,hbox4,hbox5,hbox6);
              vbox1.setPadding(new Insets(10,10,10,10));
              
              
              //adding a student to the arraylist
              addbtn.setOnAction(e-&gt; {
                  
                  validation.isInt(enterIDtxt, enterIDtxt.getText());
                  String name = enterNametxt.getText();
                   int ID = Integer.parseInt(enterIDtxt.getText());
                   String Dob = enterDOBtxt.getText();
                   
                                          //validating user input
                  Student student = new Student(name,ID,Dob);
                  arraylist.add(student);
                  System.out.println(arraylist);   //to remove later   
                   
                  
              });
              
              //listing the arraylist of students
              listbtn.setOnAction(e -&gt; {
                      textArea.setText(null);
                    for(Student stu : arraylist){
                        
                         textArea.appendText(stu + &quot;\n&quot;);
                        
                        }
                  
              });
              //removing a student
                  removebtn.setOnAction(e -&gt; {
                  int ID = Integer.parseInt(enterIDtxt.getText());
                  Student studentToRemove = null;         //temporary variable to store student obj   
                      for(Student student:arraylist){
                              if(student.getID()==ID);
                              studentToRemove = student;
                      }
                          if(studentToRemove==null)
                              System.out.println(&quot;No customer found&quot;);
                          else
                              arraylist.remove(studentToRemove);          //need to throw an alert here       
              });
              
                  
              //saving everything to a txt file
                  save.setOnAction(e -&gt;{
                      
                      try {
                           File file  = new File(&quot;StudentData.txt&quot;);
                           //File to store student data
                           ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(file,true));
                           os.writeObject(arraylist);         //writting all the items too the txt file
                           os.close();
                         }
                      
                      
                      catch(FileNotFoundException e1){
                      e1.printStackTrace();
                      }
                      catch(IOException e1) {
                          e1.printStackTrace();
                      }
                      
                  });
                  
             //load everything from the txt file
                  load.setOnAction(e -&gt;{
                      
                      try {
                          textArea.setText(null);
                          FileInputStream fis = new FileInputStream(&quot;StudentData.txt&quot;);
                          ObjectInputStream ois = new ObjectInputStream(fis);
                          List&lt;Student&gt; students = (List&lt;Student&gt;) ois.readObject();
              
                           // for(Student stu : students){
                                
                                 textArea.appendText(students + &quot;\n&quot;);
                                
                               // }
                          ois.close();
              
                      } 
                      catch (FileNotFoundException e1) {
                          e1.printStackTrace();
                      }
                      catch (IOException e1) {
                          e1.printStackTrace();
                      }
                                      
                      catch (ClassNotFoundException e1) {
                          e1.printStackTrace();
                      }
                          
                  
                  });
                 
              
              Scene mainScene  = new Scene(vbox1,500,500);
              //mainScene.getStylesheets().add(&quot;application.css&quot;);
              primaryStage.setScene(mainScene);
              primaryStage.show();
              
              
          } catch(Exception e) {
              e.printStackTrace();
          }
          
          
      }
      
      public static void main(String[] args) {
          
          Application.launch(args);
          
      }
      
      
  }
  </code></pre>