I'm getting the error java.lang.NullPointerException even though I'm not using null in my code. Can you tell me why and how I can fix it?
Not with the information provided. Sorry.
Maybe you haven't initialized some value?
This is a rough example of what can cause that error: Lets say I have MainProgram.java and Data.java. In MainProgram.java I have: ``` ArrayList<Data> data; ``` So that `data` can be used as an array list of Data.java defined objects. Then I go on my merry way and use it: ``` data.add(new Data(1,2)); ``` This will generate a null pointer error. That first thing above is a declaration of what type `data` is. If I forget to do something like `data = new ArrayList<Data>` to initialize it in there, then I can't use it. You probably have some situation like that going on, which is what blurbendy is talking about.
Join our real-time social learning platform and learn together with your friends!