Copying ArrayList to Array of primitives - is there some bypass to this given this spec?
<p>So I'm to write a simple thing which reads an input file till EOF reached - the file consists of int-double pairs. I'm to calculate the average of all the elements in the second array and finally have both sets of data stored in respective arrays of primitive data types.</p>

<p>Of course the task is easy so the question isn't directly about it - rather, about the <em>array</em> part. As I don't know how many pairs I'll have to store, I use two ArrayLists to store it. The spec strictly points that in the end, however, both ints and doubles have to be store in primitive arrays - and here comes my question. Is there some faster way to do this than just copying the ArrayList to a primitive type array? I can't use an array from the beginning since I don't know the size or even an upper bound and using toArray() also woulnd't work as I have to have primitive int[] and double[] in the end, not objects of Integer[] and Double[].</p>
