title: Java ArrayList copy
body: <p>I have an <code>ArrayList</code> <code>l1</code> of size 10. I assign <code>l1</code> to new list reference type <code>l2</code>. Will <code>l1</code> and <code>l2</code> point to same <code>ArrayList</code> object? Or is a copy of the <code>ArrayList</code> object assigned to <code>l2</code>?</p>
  
  <p>When using the <code>l2</code> reference, if I update the list object, it reflects the changes in the <code>l1</code> reference type also.</p>
  
  <p>For example: </p>
  
  <pre><code>List&lt;Integer&gt; l1 = new ArrayList&lt;Integer&gt;();
  for (int i = 1; i &lt;= 10; i++) {
      l1.add(i);
  }
  
  List l2 = l1;
  l2.clear();
  </code></pre>
  
  <p>Is there no other way to assign a copy of a list object to a new reference variable, apart from creating 2 list objects, and doing copy on collections from old to new?</p>