Q:

Converting a Double Array list to a double array

I am wanting to convert my double ArrayList to a double array but I am unsure how. Here is my current code listing :
ArrayList<Double> aL= new ArrayList<Double>();  
double x[] = new double[aL.size()];
aL.add(10.0);  
aL.add(5.0);  
aL.add(2.0);
for(int i =0; i < x.length; i++){
//some code
}

But then I am not sure where to go and I am unable to find something on the internet/ in books to give me any insight. Thanks.

A:

First, you need to create your ArrayList.  Then you need to create your array.
List<Double> aL= new ArrayList<Double>();  
aL.add(10.0D);  
aL.add(5.0D);  
aL.add(2.0D);

double x[] = new double[aL.size()];
for(int i = 0; i < x.length; i++){
     x[i] = al.get(i);
}

You can use an ArrayList method to copy the ArrayList to an array.
List<Double> aL= new ArrayList<Double>();  
aL.add(10.0D);  
aL.add(5.0D);  
aL.add(2.0D);

double x[] = aL.toArray();

