I was trying to use this code, it doesn't show anything wrong with it when I wrote it down, but when it comes in contact of the edge of the map an error message pops up saying; at hook.Vanish(hook.java:35) at hook.act(hook.java:23). (Hook is the subclass I wanna make it disappear. And vanish is what the method is called which tries to make it vanish.)
public void Vanish()
{
World world;
world = getWorld();
if (getX() >= getWorld().getWidth()-1)
world.removeObject(this);
if(getY() >= getWorld().getHeight()-1)
world.removeObject(this);
}

