Need some help pls! whenever I click on the modify button it removes everything fine however gives me a null pointer exception on the indicated line. Please can someone explain how to fix it.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class modifybutton here. * * @author (your name) * @version (a version number or a date) */ public class modifybutton extends buttons { public int traction=0; public int baysize=0; /** * Act - do whatever the modifybutton wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if (Greenfoot.mouseClicked(this)) { getWorld().removeObjects(getWorld().getObjects(playbutton.class)); getWorld().removeObjects(getWorld().getObjects(exitbutton.class)); getWorld().removeObjects(getWorld().getObjects(modifybutton.class)); getWorld().setBackground(new GreenfootImage("modification background.fw.png")); //this line then comes up with a nullpointerexception getWorld().addObject(new skisbutton(), 3 , 2); getWorld().addObject(new tracksbutton(), 5 , 2); getWorld().addObject(new wheelsbutton(), 7 , 2); getWorld().addObject(new largebaybutton(), 7 , 3); getWorld().addObject(new mediumbaybutton(), 5 , 3); getWorld().addObject(new smallbaybutton(), 3 , 3); getWorld().addObject(new backbutton(), 8 , 7); } } }