I needed to change variables inside an inner class and I got the infamous \"Cannot refer to a non-final variable inside an inner class defined in a different method\" error.
I posted a similar answer in my other thread here. Basically the idea is to create a "wrapper" which wraps over pretty much any Object
type. Since final
in Java stands for "no reassignment" and not "constant", this trick pretty much works out fine. But as mentioned in the original post, make sure you tread with caution when using it in a multi-threaded environment.