|
|
Gail Shaw wrote:
> boolean hasShip() {
> if (localShip!=null)
> return true;
> else
> return false;
> }
This cannot possibly throw a null pointer exception.
> Node currentNode = Universe.space[i][j]; // Have checked and this is
never
> null.
> if (currentNode.hasShip()) { // <-- This line sometimes throws a
> NullPointerException
The only way for a null pointer exception to occur is if currentNode is
null.
Looks like whatever initialises Universe.space isn't doing it right, or
has some kind of intermittent bug or something. (Alternatively, the
exception isn't comming from where you say it is.)
Realistically, you'll probably need to run the code through a debugger
and make it halt execution when it hits the exception, then poke around
and examine the system state...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|