Savneet Kaur Savneet Kaur -4 years ago 50
Java Question

Error in Earthquake Report App

i am building an earthquake report app and getting this error. I searched all over Google + Stack OverFlow + udacity forums still didnt find the answer.

the error says String can't be converted into int .But I have used the exact code as mentioned in udacity.

enter image description here

The error says:

getMagnitudeColor(int) in EarthquakeAdapter cannot be applied to (java.lang.String)

Answer Source

Is it possibly because the JSON element that you are referencing has the number as a String datatype rather than an Integer? If so, you can fix it with the following:

int magnitudeColor = getMagnitudeColor(Integer.parseInt(currentEarthquake.getMagnitude());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download