Я хочу закодировать игру «Четыре победы» с JavaFX, но при объявлении двумерных «полей» TextField-Array и распечатке элементов списка я получаю исключение NullPointerException, потому что нетTextField-Objects, но только null-Objects.Может ли кто-нибудь помочь мне с этим?
@FXML Button button1, button2, button3, button4, button5, button6, button7;
@FXML TextField field00, field01, field02, field03, field04, field05,
field10, field11, field12, field13, field14, field15,
field20, field21, field22, field23, field24, field25,
field30, field31, field32, field33, field34, field35,
field40, field41, field42, field43, field44, field45,
field50, field51, field52, field53, field54, field55,
field60, field61, field62, field63, field64, field65;
@FXML TextField[][] fields = {
{field00, field01, field02, field03, field04, field05},
{field10, field11, field12, field13, field14, field15},
{field20, field21, field22, field23, field24, field25},
{field30, field31, field32, field33, field34, field35},
{field40, field41, field42, field43, field44, field45},
{field50, field51, field52, field53, field54, field55},
{field60, field61, field62, field63, field64, field65}
};
ArrayList<ArrayList<TextField>> freeFields = new ArrayList<>();
private String player;
private int turn = 1;
public void initialize(){
player();
System.out.println(field00.getClass());
for(int i = 0; i < fields.length; i++){
ArrayList<TextField> arrayList = new ArrayList<>();
for(int j = 0; j < fields[0].length; j++){
arrayList.add(fields[i][j]);
}
freeFields.add(arrayList);
}
}