title: Loading an ArrayList from a file
body: <p>I've just saved an arraylist to a file. Now I want to load it back into my program, and it doesnt work. here is my code for it:</p>
  
  <pre><code> public void loadgame(){
      try {
          System.out.println("1");
          FileInputStream prein = new FileInputStream("saved game.txt");
          System.out.println("2");
          ObjectInputStream in = new ObjectInputStream(prein);
          System.out.println("3");
          kortene = (ArrayList&lt;Kort&gt;)in.readObject();
          System.out.println("4");
          in.close();
  </code></pre>
  
  <p>Iit gets an error after 3, and the error is: </p>
  
  <pre><code>java.io.InvalidClassException: vendespil.Kort; local class incompatible: stream classdesc serialVersionUID = -8031146399228259151, local class serialVersionUID = -3342687010032791159
  </code></pre>
  
  <p>my problem isn't how to do this, but that i've done just what other people have said, and yet it doesn't work, my question is, why do i get that error, and if its because i change the ArrayList between saving it and loading it, i mean, i don't change the file, but i do clear the ArrayList before trying to load it.</p>