NullPointerException

classic Classic list List threaded Threaded
2 messages Options
Tiny Tiny
Reply | Threaded
Open this post in threaded view
|

NullPointerException

I've got a HashMap<Integer, Object> and I've got a getter function for it as such:

public Boolean getBoolean(int index){
     return (boolean) watcherMap.get(index);
}
When calling this class, I get this error

Exception in thread "" java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Boolean
at java.lang.Thread.run(Unknown Source)
John John
Reply | Threaded
Open this post in threaded view
|

Re: NullPointerException

Object handled can hold any object reference. Seems like it holds String object in your case and have dificulty casting it to boolean.