-2

I am attempting to display a time on a JLabel and when I attempt to create a timer where the run() method changes the text, it is expecting my time variable to be a final one element array as seen below: enter image description here

Why is timeDown supposed to be final?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
isakbob
  • 1,439
  • 2
  • 17
  • 39

1 Answers1

1

Variables accessed in an anonymous class which are defined in the enclosing scope must be final or effectively final.

See: https://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html

Ben Anderson
  • 496
  • 4
  • 11