title: Java ArrayList serialized file write uses ID and records changing items incorrectly
body: <p>I'm trying to use an ArrayList to record the states of an Object as it changes to a file.  I am adding the object to the file each time it changes.  When I look back at the file when the process is complete, it just has multiple copies of the latest values of the object.  I understand that this may be because the OutStream Class uses a single reference to the object.  This would be fine for a data stream but is useless for a file output.  Any ideas how I can solve this?  </p>
  
  <pre><code>    ArrayList &lt;Reel&gt; reels = new ArrayList&lt;Reel&gt; () ;
      Reel reel = new Reel();
          reel.name = "Default";
          reel.innerDiam = 125;
          reel.outerDiam = 200;
          reel.leftEdge = 150;
          reel.rightEdge = 300;
          reel.saved = false;     //reels = new Reel[100];
      reels.add(reel);
          reel.name = "LRF1A";
          reel.outerDiam = 225;
      reels.add(reel);    
      try { 
          ObjectInputStream reeliStream = new ObjectInputStream(new FileInputStream("Reels.ser"));
          reels = (ArrayList&lt;Reel&gt;) reeliStream.readObject();
      } catch (Exception eI) {
      System.out.println("Creating new Reels Repository File");
          try {
              ObjectOutputStream reeloStream = new ObjectOutputStream(new FileOutputStream("Reels.ser"));
              reeloStream.writeObject(reels);
          } catch (Exception eO){
              System.out.println("Failed to created new Reels Repository file.");
          }// try Read Reels
      }//Try Write Reels
      reel = reels.get(1);
  </code></pre>