Hello all. So I'm currently in the process of writing a little java program and I'm getting a NullPointerException and I have no idea why it's giving me it. I know what it means, but as far as I can see, it shouldn't happen.

Here's a (very) small part of my code (of my Game class):

private GUIHandler handler;
handler = new GUIHandler(this);

And the constructor of GUIHandler:

public GUIHandler(Game game)
{
System.out.println(game);
this.game = game;
}

I think this is where it throws the error (discovered that by printing a lot to the console (basically before every statement) and then checking where it happened), but I have no idea why. Does anyone have any idea?

I know this is not the most optimal place to ask, but I know that there are quite a few people here that might be able to help me and I really just needed an excuse to make a forum GA. :p

https://www.steamgifts.com/giveaway/CHwhA/chroma-squad

EDIT: nevermind, I'm an idiot. I forgot to initialize an ArrayList...
I feel so stupid now...

7 years ago*

Comment has been collapsed.

Bump for the GA.
Writing code makes most people feel stupid :) Been there, done that.

7 years ago
Permalink

Comment has been collapsed.

Yeah, at school we had an issue with an app we were building. We spend about 3 weeks trying to find what it was. Turned out that we forgot one "s" somewhere...

7 years ago
Permalink

Comment has been collapsed.

I know the feeling. I had to debug a project with over 350k lines of code for a client only to find out the culprit was a misplaced "}". The funny thing is by looking through their versioning system I noticed they used it like that for years, it went through multiple iterations and it even survived a code refactoring a few months before they decided to find out what was going on.

7 years ago
Permalink

Comment has been collapsed.

350k? Damn. I currently have to go through 2k lines of code that I've written myself. I can't even begin to imagine how bad 350k from someone else must be...

7 years ago
Permalink

Comment has been collapsed.

I know nothing about Java but thankfully you've already solved it.
Thanks for the squad :D

7 years ago
Permalink

Comment has been collapsed.

NullPointerExeptions mostly happen when you forget to initialize something;)

7 years ago
Permalink

Comment has been collapsed.

Yeah, I know that. But when figuring out where it was it looked like it was what I posted, so I was really confused...

7 years ago
Permalink

Comment has been collapsed.

Dont feel bad, you learn something new and you solved it yourself :)

7 years ago
Permalink

Comment has been collapsed.

id10T errors are nothing to be ashamed of. you learn from them. ^^

7 years ago
Permalink

Comment has been collapsed.

Bump

7 years ago
Permalink

Comment has been collapsed.

Good to see you figured it out, i would not have been much of a help anyways. Thanks for the gib!

7 years ago
Permalink

Comment has been collapsed.

View attached image.
7 years ago
Permalink

Comment has been collapsed.

I love that show! I really need to watch again...

7 years ago
Permalink

Comment has been collapsed.

Bump!

7 years ago
Permalink

Comment has been collapsed.

Bump!

7 years ago
Permalink

Comment has been collapsed.

Glad to see you figured it out... I wouldn't have been able to help anyway

7 years ago
Permalink

Comment has been collapsed.

Closed 6 years ago by Dnomyar96.