title: What is the best way to store history of state and payout as a list in Java
body: <p>I have a problem with my list that store history.</p>
  <p>Basically i have matrix of cells, and each cell got state, payout, and history. The history is an object that contain veriables <code>char state</code> and <code>double payout</code>, but i have a lot of problems with refferences. While i am trying to copy whole history, there is creating some reference that i dont know how to handle.</p>
  <p>Let me show you the code (i know the copying way with two objects as a cells is stupid, but i was trying every possible way to get rid of those references):</p>
  <pre><code>public class Cell {
  
      public char state;
      public double payout;
      
      public class History{
  
          public char state='E';
          public double result;
          
          public History (char state, double result)
          {
              this.state=state;
              this.result=result;
          }
          public History (History history)
          {
              this.state=history.state;
              this.result=history.result;
          }
          public char getState()
          {
              return state;
          }
          public double getResult()
          {
              return result;
          }
      }
  
  
      public LinkedList&lt;History&gt; history;
  
      public Cell (Settings settings)
      {
          this.state=settings.state;
          this.payout=0;
          history= new LinkedList&lt;History&gt;();
      }
      public void copyCell ( Cell dest, Cell temp)
      {
          dest.state=temp.state;
          dest.payout=temp.payout;
          
          dest.history= new LinkedList&lt;History&gt;();
          
          for (int i =0; i&lt;temp.history.size(); i++)
          {
              double result1=temp.history.get(i).result;
              char state1=temp.history.get(i).state;
              
              dest.history.add(new History (state1,result1));
          }
      }
  }
  </code></pre>
  <p>What im doing wrong? I think i dont know the difference between copying veriables and making reference to the object. Can somebody explain me this?</p>