• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps In convertible Types: Cannot cast 'java.lang.Object[]' to 'java.lang.Double'

I am trying to retrieve data from foursqaure API, however, when I try to retireve the places rating I am getting the error message which says In convertible Types: Cannot cast 'java.lang.Object[]' to 'java.lang.Double' . Please help.

I am getting the error message for this line below:
Code:
  this.itemrating = (Double)temprating.toArray();
Please can you please and sort out the issue I am currently facing.
 
Last edited:
You've declared itemrating as a Double, not an array of Double. It should be

Code:
private final Double[] itemrating;

and your other line should be

Code:
this.itemrating = (Double[])temprating.toArray();
 
btw you don't actually need the explicit cast statement, as the compiler is clever enough to figure out that toArray() returns a Double[]. So this should work

Code:
this.itemrating = temprating.toArray()
 
Back
Top Bottom