I’m having an issue where I have a player object that I’m trying to send to a method, and it doesn’t work. As far as I can tell, however, it should. Any ideas?
The line on which I find the error:
keybl.playerUpdate(player);
Wherein “keybl” is a KeyListener that is initialized and is functioning in code before this runs, “playerUpdate” is a method seen below, and “player” is a Player object which is, in fact, initialized properly.
public void playerUpdate(Player somePlayer) {
user = somePlayer;
}
Wherein “user” is a class variable of type “Player” that is set to a different player object when this is run.
Any ideas?
If the exception is on this line:
then it must be that
keyblis null. Add oneSystem.out.println("keybl: " + keybl);before this line and you should see it printingnullat some point (or to be precise – before the exception is thrown).