Skip to content
Advertisement

Calling a Method in a running Thread Object [closed]

I’m a Java beginner. I want to call a Method in a running Java Thread Object. It always throws this exception:

Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException: Cannot invoke “Graphic_handler.next()” because “this.this$0.grap” is null

JavaScript

(Code is simplified)

Here is the part of the Code where I call the Method:

JavaScript

Im trying to call the Methods next() and last() here.

Advertisement

Answer

What’s going on is you have a local variable that is hiding the instance variable.

JavaScript

To fix this just remove the declaration in front of grap in the method.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement