List.toArray(T[])
takes an array for Wrapper type, not primitive type.
You should do it like this:
Float result[] = arrResult.toArray( new Float[arr.size()]);
But, that's really not required. Because, now you would have to convert this to primitive type array. That is too much right?
You can directly create a float[]
array, rather than going through an ArrayList<Float>
. Just change your arrResults
declaration to:
float[] arrResults = new float[arr.size()];
And in for loop, add elements to the array using:
for(int i = 0; i < arr.size(); ++i) {
arrResults[i] = arr[i];
}