title: How can I make this object mutable
body: <p>I have this simple immutable object:</p>
  
  <pre><code>public class Alt {
  public LinkedList&lt;Integer&gt; list = new LinkedList&lt;Integer&gt;();
  
  public void refresh() {
      Random rand = new Random();
  
      list.clear();
  
      for (int i = 0; i &lt; 50; i++) {
          list.add(rand.nextInt(32));
      }
  }
  
  public void compare(Alt alt) {
      for (int i = 0; i &lt; list.size(); i++) {
          System.out.println(alt.list.get(i) + " " + list.get(i));
        }
     }
  }
  </code></pre>
  
  <p>However this class is an immutable object, for example when I run: </p>
  
  <pre><code>Alt a = new Alt();
  a.refresh();
  Alt b = a;
  b.refresh();
  
  a.compare(b);
  </code></pre>
  
  <p>The values that return are the same, the object b act's like its a shortcut to the object a and is more or less a duplicate. Is there a way to make it so that b is separate? Or am I doing this in completely the wrong way.</p>