Hi, I need help on solving a Nullpointer exception:
This problem has to do with three classes:
Sheep class:
method()
{
world01 world = (world01)getWorld();
rock rock = world.getrock();
rock.lostlife();
}
world01 class:
public world01(Sheep sheep) // left the sheeps away... (not really, just here)
{ rock rock = new rock();
addObject(rock, 345, 300);
rock = new rock();
addObject(rock, 242, 225);
}
private rock rock;
public rock getrock()
{
return rock;
}
rock class:
public void lostlife()
{
getWorld().removeObject(this);
}
I can compile this section, but if I acces the method(), I get a nullpointerexception... help please?