A non-generic toArray may not be optimal, I would recommend using a for loop instead:
Long[] v = new Long[entry.getValue().singleValues.size()]; int i = 0; for(Long v : entry.getValue().singleValues) { v[i++] = v; }
Now you have an array of Long objects instead of Object . However, Long is an integral value, not a floating point. You should be able to throw, but it smells like a major problem.
You can also convert directly instead of the Long array:
double[] v = new double[entry.getValue().singleValues.size()]; int i = 0; for(Long v : entry.getValue().singleValues) { v[i++] = v.doubleValue(); }
Concept: you should not try to convert the array here, but instead convert each element and save the results in a new array.
source share