Looking for a better way to convert ArrayList<Double> to double[] array
<p>I've been searching a solution for converting an ArrayList to a double[] array. After reading a few questions on the same issue, i figure out a solution. This is how i work now.</p>

<pre><code>  public static double[] listToArray(List&lt;Double&gt; arr){   
  double[] result = new double[arr.size()];
  Iterator&lt;Double&gt; itr = arr.iterator();
  int i = 0 ; 
  while(itr.hasNext()){
      try{
          result[i] = Double.parseDouble(itr.next().toString());
          i++;
      }catch(IndexOutOfBoundsException e){
          System.out.println("OutOfBouds");
      }
  }      
  return result;
  }
</code></pre>

<p>This is a rather nasty way. I know there are some APIs that can do what i want. But in that case, i will bring extra complexity to my project, which  is not what i want to see. Can anyone give me a better solution??</p>
