I have the below piece of code:
Integer mRuntime = (Integer) movie.get("runtime");
String movieRuntime;
if(mRuntime == null){
movieRuntime="*Not Available*";
} else{
movieRuntime = String.valueOf(mRuntime);
}
In the above code I am trying to check the value of runtime which is an integer and trying to convert the value to String if it is not NULL. if it is null I am writing a custom message to String telling that it is not available.
But when I try to execute the code I am getting the below message:
nested exception is java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at
Integer mRuntime = (Integer) movie.get("runtime");
(Integer) movie.get("runtime")
seems to return string, not integer. Double check it. – Pshemo Mar 23 at 20:00