title: Error converting from ArrayList to double[]?
body: <p>I have an <code>ArrayList</code> called <code>out</code>, and I need to convert it to a <code>double[]</code>. The examples I've found online have said two things:</p>
  
  <p>First, try:</p>
  
  <pre><code>double[] d = new double[out.size()];
  out.toArray(d);
  </code></pre>
  
  <p>However, this produces the error (eclipse):</p>
  
  <pre><code>The method toArray(T[]) in the type List&lt;Double&gt; is not applicable for the arguments (double[]).
  </code></pre>
  
  <p>The second solution I found was on StackOverflow, and was:</p>
  
  <pre><code>double[] dx = Arrays.copyOf(out.toArray(), out.toArray().length, double[].class);
  </code></pre>
  
  <p>However, this produces the error:</p>
  
  <pre><code>The method copyOf(U[], int, Class&lt;? extends T[]&gt;) in the type Arrays is not applicable for the arguments (Object[], int, Class&lt;double[]&gt;)
  </code></pre>
  
  <p>What is causing these errors, and how do I convert <code>out</code> to <code>double[]</code> without creating these problems? <code>out</code> indeed holds only double values.</p>
  
  <p>Thanks!</p>