Attempt to invoke virtual method '' on a null object reference [duplicate]
-1
0
This question already has an answer here:
What is a NullPointerException, and how do I fix it?
12 answers
I'm getting this error "Attempt to invoke virtual method 'java.lang.String eecs1022.caps.Game.qa()' on a null object reference" I just want to know why im getting this error and how I can work around it. The game object is returns a string but for some reason it says its a null object. Here is my main class and my game class. MAIN: private Game game; private String question = ""; private String answer = ""; private int score = 1; private int qNum = 1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);