I want change a variable when I click a button in JavaFX. But when I try to use the variable from the program it says
local variables referenced from inside a lambda must be final or effectively final.
I can't make it final though because I need to change it so I can use it. My code looks like this
Button next = new Button();
next.setText("next");
next.setOnAction((ActionEvent event) -> {
currentLine++;
});
what can i do to get around this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…