Cannot refer to a non-final variable inside an inner class defined in a different method?

Java doesn't support true closures even though using an anonymous class like you are using here (new TimerTask() { ... }) looks like a kind of closure.

To avoid strange side-effects with closures in java variables referenced by an anonymous delegate must be marked as final, so to refer to lastPrice and price within the timer task they need to be marked as final.

The error message says exactly what's wrong: the I variable isn't final, but you're trying to refer to it within an anonymous inner class.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions