These variables will indeed collect garbage as soon as the GC runs when the method completes.
The final keyword is really present as a hint: this variable is created once, you should not touch it in the body of the method itself. Similarly, declaring the final method parameters prohibits their reuse (which, imho, is a good thing).
Please note that the keyword only affects the link to the object: this does not mean that the methods in this link to the object that change its internal state will stop working (typical example: setters).
Another note: when you omit the final keyword and you do not change the variable in the body of your method, the JVM is smart enough to optimize this case. So you can omit this. Regardless of whether you use it and where you use it, it is a matter of taste / coding style.
And finally, it is good practice to declare public static variables as final: otherwise everything can change it! Think string constants etc.
source share