title: Using Arraylist addAll() to create a new list with new objects with different reference
body: <p>I want to merge two arraylists to one new arraylist, and iterate through the list. Before I make actions on my new arraylist, I want to multiple some value times -1. The problem however is, that when using addAll() I also multiple my old arraylist. </p>
  
  <pre><code>public Polynoom subtract (Polynoom that) {
      Polynoom subtract = new Polynoom(); 
      subtract.termen.addAll(that.termen);
      for (int i = 0; i &lt; subtract.termen.size(); i++) {
          subtract.termen.get(i).coef = subtract.termen.get(i).coef * -1; 
      }
      subtract.termen.addAll(this.termen);
      Collections.sort(subtract.termen);
      subtract.removeDoubles(); 
      return subtract; 
  
  }
  </code></pre>
  
  <p>My Polynoom class looks like this: </p>
  
  <pre><code>   class Polynoom implements PolynoomInterface {
  
  
          ArrayList&lt;Paar&gt; termen = new ArrayList&lt;Paar&gt;(); 
  
          Polynoom() {
              termen = new ArrayList&lt;Paar&gt;();
          }
  }
  </code></pre>
  
  <p>The problem is (i think): that when using addAll() it creates REFERENCES instead of new copies, therefore changing the elements will change both. What is nice way to overcome this problem? </p>
  
  <p>I can of course create a new pair instead of a Polynoom an add this pair to a new Polynoom but I don't think that is really nice code. Does someone has a better idea?</p>