This is just for understanding. We are using IntelliJ IDEA in our project (I'm much more an Eclipse person though, hence the question.) I activated the 'Inspect Code' action and noticed that it often suggests that some variable can have a final modifier. Ok that is nice but I don't always understand the reason why it chooses some variables.
As I understand it a variable declared within a local method exists only within that method and is then later garbage collected once the method is exited, and variables passed are referenced. The final modifier makes the variable non-changable. That is how I understand it.
I asked some other 'more experienced' developers in my team about why and what impact this has. (Kinda seemed nit-picky to me). They stated that it improves the garbage collection. That is what I don't understand, how does it improve the gc? I can understand a tool looking at the code, seeing that a variable is not modified and then suggest setting it to final, but performing this action to improve gc is beyond my knoweldge. They were not able to explain how or why this occurs, but I am under 'orders' to learn from their vast experience. (Personnally, I believe that they are a bit wacked at times, for whenever something comes up that they can not explain it then becomes a pattern or concept that arose first within PowerBuilder and is therefore a further explination why Java copies from PB and that PB should be resurrected, but that is a laugh for another time.)
Anyone here able to explain how 'final' improves gc?