File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 19541
    
  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
Issue while invoking JNDI in a JMS example in glassfish
Please need help with calculator program...
Synchronize the way threads(players) take their turn.
ConcurrentModificationException driving me nuts.
Need help with Mini Telephone Directoy program please