[SOLVED] Null pointer exception
Basically, my code is like this:
It compiles, but I get a run time error saying there's a null pointer exception where I've put the **. I'm not really sure what the problem is, I've initialised button1 and my array list so neither are null, and I've used an if statement so it only adds to array list if button1 is NOT null. i've tried initializing button1 to null, nothing seems to be working.
public class Viewer()
private ArrayList<Button> buttonsList;
private Button button1;
buttonsList = new ArrayList<Button>();
public void addButtons()
//other code emitted
button1 = new Button("title");
if (button1 != null)
Any suggestions would be much appreciated!