ArrayList add() function overwrites all the elements (processing/java) : <p>So I am trying to shuffle the same ArrayList (knots) 50 times in a for-loop and adding the shuffled list to another ArrayList (gen0). But every time I add  a new ArrayList it overwrites all existing ArrayList-elements to the same ArrayList I just added, can someone tell me why?</p>

<pre class="lang-java prettyprint-override"><code>ArrayList&lt;ArrayList&gt; seed(ArrayList&lt;PVector&gt; knots) {

  ArrayList&lt;ArrayList&gt; gen0 = new ArrayList&lt;ArrayList&gt;();
  for(int i=1; i&lt;=50; i++) {

    Collections.shuffle(knots);

    gen0.add(knots);    
  }

  return gen0;
}```
</code></pre>
