According to Effective Java 3rd Edition, all local variables are implicitly
made final by the JVM (and thus receiving the same JVM optimizations as a
final variable) without requiring use of the keyword as long as you only
set the value once. So this becomes an unnecessary use of the keyword
final which
really just adds noise to the code (one more word on many lines) much like
unnecessary uses of this. on references to class fields. The only context
where it's still valuable to use final is on class fields and constants
where it provides concurrency guarantees.

It may be useful to temporarily mark a local variable as final while
performing a refactoring. See Martin Fowler's book for various refactorings
in which he does this.

There really is no value in retaining the keyword on a local variable any
longer, so I think we should avoid using it in the same way we avoid
unnecessary uses of this. on references to class fields. It's all just more
noise in the code.

Reply via email to