Your array is null and you are trying to get an index into it. That is what causes the NullPointerException . Your array must be initialized before you can use it to store your buttons.
If you need an array of nine buttons, change this line:
Button buttons[] = null;
For this:
Button buttons[] = new Button[9];
In addition, you have a member of the Button buttons[] class and a local function variable, also called Button buttons[] . If this is intentional, then be sure to continue. Otherwise, you will need to change your line as follows:
buttons[] = new Button[9];
MCeley
source share