I try to create a class in which there is a text field and a field with a number, but when I try to link them through a lambda expression, I get a message that the field must be final or effectively final.
class Stranica{ private final int[][] kolichestvo = new int[24][4]; private TextField[][] tfPolVvod = new TextField[24][4]; { for (int i = 0; i < 24; i++) { for (int j = 0; j < 4; j++) { TextField tf = new TextField(); tf.setPrefWidth(50); tf.setOnKeyReleased(pdj ->{ if(!tf.getText().matches("\\d+")){ tf.setText("0"); tf.selectAll(); //в следующей строке будет ругаться на то что поле не финальное }else kolichestvo[i][j]=Integer.parseInt(tf.getText()); }); tfPolVvod[i][j]=tf; } } } }
Tell me how to connect them correctly.