I have a best practises kind of question,
I have written an animated analog clock class which uses the Swing
Timer
to repaint the position of the second, minute and hour hands onto a clock which is called once per second.
I use three int
variables to store the temporary values of the current secs, mins and hours.
If the paintComponent()
method is the only method which uses these three variables would it be more efficient for the processor load of the program if the variables were declared globally, so that they are created once and simply edited every time that the timer calls paintComponent()
, or would it be better to declare the variables locally in the paintComponent()
method's scope each time as used?