I have set up the following ArrayList:
ArrayList<Integer> myIntegerValues = new ArrayList<Integer>();
myIntegerValues.add(0);
myIntegerValues.add(1);
myIntegerValues.add(0);
myIntegerValues.add(1);
I want to convert this to a double[]
and run a simple piece of code like this
double[] myList = {1.9, 2.9, 3.4, 3.5, 2.9, 3.8, 10.2};
for (int i = 0; i < myList.length; i++) {
System.out.println(myList[i] + " ");
}
How do I convert an ArrayList
to a double[]
?
I found this link How to cast from List<Double> to double[] in Java? but I'm not sure if this answers my question or not.