0

I am a hobbyist Just starting with java about 5 months ago. I created this project for just fun. Coming here was my last resort, normally I can solve these problems on my own. I keep getting this error occasionally when I move my player.

Exception in thread "Thread-2" java.lang.NullPointerException
at java.util.LinkedList.node(Unknown Source)
at java.util.LinkedList.get(Unknown Source)
at Handler.render(Handler.java:55)
at Game.render(Game.java:136)
at Game.run(Game.java:76)
at java.lang.Thread.run(Unknown Source)

Link To Source I have plenty of other problems with this project this is only my second game I've attempted to make on my own If you could help With any other errors you see that whould be very helpful.(Have never Used Stack before)

  • Can you paste the relevant source code into the question? Nobody wants to go navigating through your project structure to find where the problem might be. – Dawood ibn Kareem Dec 18 '17 at 04:43
  • 1
    @MadProgrammer I don't think it's helpful to flag this as a duplicate. OP can't exactly "fix" what's going on in `java.util.LinkedList`. The problem is the way it's being used. Knowing how to fix NullPointerExceptions in general isn't much use here. – Dawood ibn Kareem Dec 18 '17 at 04:47
  • To me, this looks like a thread safety issue. Are you accessing the `LinkedList` in two different threads - trying to read it in one thread at the same time as you're changing it in the other? – Dawood ibn Kareem Dec 18 '17 at 04:51
  • @DawoodibnKareem The process of diagnosing and resolving a `NullPointerException` always follows the same course of action(s). The fact that the symptom has shown up in `java.util.LinkedList.node` is more likely a side effect of something OP is doing else where in their code the something that's wrong with the core library - Would you prefer the question be closed for a lack of a runnable example? – MadProgrammer Dec 18 '17 at 04:51
  • I disagree that diagnosing and resolving NPEs always follows the same course of action. In my experience, it really doesn't. I don't see the point in refusing to help them with their problem (and more importantly, preventing _others_ from helping them with the problem), just because it has a similar symptom to some other common problem. – Dawood ibn Kareem Dec 18 '17 at 04:53
  • And in answer to _"... would you prefer the question be closed for a lack of a runnable example ..."_, well, no, I'd prefer the OP to _provide_ a runnable example so that he/she can be helped. That's unlikely to happen if you've flagged the question as "no help available here". – Dawood ibn Kareem Dec 18 '17 at 04:54
  • @DawoodibnKareem I'm not refusing to help them, I'm asking them to try and help themselves and not clutter the forum. You are, of course, free to vote to re-open the question. *" well, no, I'd prefer the OP to provide a runnable example so that he/she can be helped"* so would I, but in my experience we end up with the posting code into the comments section, complaint that there is to much code or just generally ignoring the request. The OP still has the opportunity to craft a new question which better meets the forum requirements – MadProgrammer Dec 18 '17 at 04:54
  • No, I _can't_ vote to re-open the question. I can hammer it open, of course, but that would be implying that my opinion is worth more than yours. I'm not that arrogant. I just think the matter is worth discussing. – Dawood ibn Kareem Dec 18 '17 at 04:55
  • @DawoodibnKareem That is, of course your choice, and I appreciate the conversion, but in it's current state, we can't help the OP, I prefer they took the time craft a better question with a runnable example and avoid other people posting "guess" answers, of course, that's just my opinion – MadProgrammer Dec 18 '17 at 04:58
  • Sure, I agree wholeheartedly with your last comment. I just don't want to see OP discouraged from making this into a better question. – Dawood ibn Kareem Dec 18 '17 at 04:58
  • Welcome to SO! In order to help us help you, might consider having a look at [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) to understand better the information we might need to help you and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) which goes a long way to removing any guess work and providing context to the question, as it might help others as well in the future – MadProgrammer Dec 18 '17 at 05:08
  • @DawoodibnKareem I only made a download to the entire source because I didn't really know where the problem was. It may be coming from me assigning 4 vars to 4 objects then ounce they are destroyed the var is set to null. Again I am very new to java. – user9111847 Dec 18 '17 at 23:45

0 Answers0