-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
  • 166,747
  • 40
  • 210
  • 420
isakbob
  • 1,330
  • 2
  • 14
  • 36

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
  • 379
  • 4
  • 10