This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes NullPointerException with a foreach statement? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NullPointerException with a foreach statement?" Watch "NullPointerException with a foreach statement?" New topic
Author

NullPointerException with a foreach statement?

Josh Rodrigues
Greenhorn

Joined: Apr 14, 2010
Posts: 17
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

Joined: Feb 23, 2007
Posts: 1561
Do you know for a fact that none of the Player objects held in Server.playerHandler.players are null?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

And are you sure that neither Server.playerHandler and Server.playerHandler.players are null?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

CarefullyChooseOneForum while posting. Moving to Beginning java forum.


apigee, a better way to API!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException with a foreach statement?
 
Similar Threads
ConcurrentModificationException driving me nuts.
Issue while invoking JNDI in a JMS example in glassfish
Please need help with calculator program...
Synchronize the way threads(players) take their turn.
Need help with Mini Telephone Directoy program please