Link to home
Start Free TrialLog in
Avatar of MarkLoveExEx
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

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[]

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

i think you mixed Double and double, to start with...
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MarkLoveExEx
MarkLoveExEx

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.
:)