title: How to copy elements from an ArrayList to another one NOT by reference?
body: <p>I'm trying to copy each element from one ArrayList (av) to another one (copia). The thing is that they're copied by reference, so whenever I make any changes in the original one, the copy is modified as well. Of course, this behavior is not wanted. How should I write this method?</p>
  
  <pre><code>public void copiarArrayList(ArrayList&lt;Articulo_Venta&gt; copia, ArrayList&lt;Articulo_Venta&gt; av){
      copia.clear();
      for (int i = 0; i &lt; av.size(); i++) {
          copia.add(av.get(i));
      }
  }
  </code></pre>
  
  <p>Articulo_Venta has these fields:</p>
  
  <pre><code>int codigo;
  String nombre;
  float cantidad;
  </code></pre>
  
  <p>PS: I also tried the next:</p>
  
  <pre><code>copia = new ArrayList&lt;Articulo_Venta&gt;(av);
  </code></pre>
  
  <p>but it still has its elements pointing to the original ArrayList.</p>