// This only/merely allocates an array of JButtons.
// Each element of the array is null.
JButton[][] slots = new JButton[6][7];
for(int i = 0; i < slots.length; i++) {
for(int x = 0; x < slots[i].length; x++) {
int n = i*slots[i].length + x+1;
// Instantiate each element of the array.
// Try this with and without this line.
slots[i][x] = new JButton(String.valueOf(n));
if(slots[i][x] == null)
System.out.println("slots["+i+"]["+x+"] = " +
slots[i][x]);
else
System.out.println("slots["+i+"]["+x+"].text = " +
slots[i][x].getText());
}
}