MarkLoveExEx
asked on
type mismatch (Object[] to double[]
Experts,
I am getting a type mismatch error. My List (named list) is specified as <Double>
I am attempting to convert Double to double.
But, somehow it thinks my List is of type Object (instead of Double).
What am I missing?
Thanks, Mark
I am getting a type mismatch error. My List (named list) is specified as <Double>
I am attempting to convert Double to double.
But, somehow it thinks my List is of type Object (instead of Double).
What am I missing?
Thanks, Mark
List<Double> list = new ArrayList<Double>();
for (int j = 0; j < x.TS_CREST_DATA.getItemCount(); j++) {
list.add((double) (x.TS_CREST_DATA.getValue(j).doubleValue()));
}
double[] result = new double[list.size()];
result = list.toArray(); // Type mismatch: cannot convert from Object[] to double[]
i think you mixed Double and double, to start with...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks CEHJ. My final result needed to be the primitive type double, not Double. So, I ended up doing away with the ArrayList entirely (which I discovered can't have primitives as a item type), and just used an array of doubles. I'm so used to using ArrayList, that I wasn't thinking outside the box. Thanks again. Mark
P.S. Also, fortunately I knew how many elements I needed ahead of time (and that number doesn't change), so the basic array of doubles worked just fine.
P.S. Also, fortunately I knew how many elements I needed ahead of time (and that number doesn't change), so the basic array of doubles worked just fine.
:)