If you do not mind using a third-party library, commons-lang is of type ArrayUtils with various manipulation methods.
Double[] doubles; ... double[] d = ArrayUtils.toPrimitive(doubles);
There is also an additional method
doubles = ArrayUtils.toObject(d);
Edit: answer the remaining question. There will be some overhead for this, but if the array is really large, you should not worry about that. Check it out first to make sure this is a problem before refactoring.
The implementation of the method that you really asked about will produce something like this.
double[] getDoubles(int columnIndex) { return ArrayUtils.toPrimitive(data[columnIndex]); }
Rich Seller Jul 10 '09 at 15:09 2009-07-10 15:09
source share