setOnAction restrictions and datepicker class
Clash Royale CLAN TAG #URR8PPP setOnAction restrictions and datepicker class I'm writing an application involved in time difference, there is something I don't get it, final DatePicker datePick=new DatePicker(); LocalDate time; Label label=new Label(); datePick.setOnAction(new EventHandler<ActionEvent>(){ public void handle(ActionEvent e){ time=datePick.getValue();//doesn't work, must 'LocalDate time=datePick.getValue(); label.setText(time);//doesn't work must label.setText("Time now:"+time) } }); It gives an error saying "Local variables referenced from an inner class must be final or effectively fine", anyway, all I did, declare 'time' variable inside setOnAction() and it worked, so what was wrong? and 'label.setText(time);' if I don't write some text inside, like 'label.setText("Time now: "+ time);' ,won't work too, that's weird, yet...