title: How to copy Java Collections list
body: <p>I have an <code>ArrayList</code> and I want to copy it exactly. I use utility classes when possible on the assumption that someone spent some time making it correct. So naturally, I end up with the <code>Collections</code> class which contains a copy method.</p>
  
  <p>Suppose I have the following:</p>
  
  <pre><code>List&lt;String&gt; a = new ArrayList&lt;String&gt;();
  a.add("a");
  a.add("b");
  a.add("c");
  List&lt;String&gt; b = new ArrayList&lt;String&gt;(a.size());
  
  Collections.copy(b,a);
  </code></pre>
  
  <p>This fails because basically it thinks <code>b</code> isn't big enough to hold <code>a</code>. Yes I know <code>b</code> has size 0, but it should be big enough now shouldn't it? If I have to fill <code>b</code> first, then <code>Collections.copy()</code> becomes a completely useless function in my mind. So, except for programming a copy function (which I'm going to do now) is there a proper way to do this?</p>