Im trying to run this code i have written but cannot see whats wrong with it. i get the java.lang.NullPointerException error when running it.
Basically what im trying to do is to move a background x position by using a new method i have created in Dice class (moveBackground).
The code i am running is
di.moveBackground(); where di is the object name
can any one help as i havent got a clue as im new to java
Class Called Dice only part of code is pasted here
private Square background; public Square getBackground() { return background; } public void moveBackground() /** this is what method i am trying to run */ { background.setXPos(75); }
Square class
public void setXPos(int x) { this.xPos = x; this.update(); }
Thanks in advance