Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException with a foreach statement?

 
Josh Rodrigues
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to execute a method in a different class called loadCriteria();. Whenever I try to execute that method, it returns a NullPointerException. I'm not sure why and I've used a foreach loop before.


Sorry for it being so long. The NullPointerException occurs at "p.loadCriteria();". The player instance is being called correctly, so I'm not sure why it's nulling. Help is appreciated. Thanks.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know for a fact that none of the Player objects held in Server.playerHandler.players are null?
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And are you sure that neither Server.playerHandler and Server.playerHandler.players are null?
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CarefullyChooseOneForum while posting. Moving to Beginning java forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic