Reputation: 456
I'm a bit confused, my Intellij Idea warns me if no final modifiers everywhere when possible.
Actually final is very good option, and of course its needed in lots of cases like methods parameters, constants and ... ,
But ...
Probably there are some really strong arguments why my local method variables should be final ?
Could you pls help me understand a benefit of such mass final usage ?
Upvotes: 4
Views: 3450
Reputation: 26492
A benefit of making all variables final is that it is clearly visible which variables are assigned only once. Another is that it is possible to use such a variable in an anonymous class without having to make it final (because it already final but this benefit has disappeared with Java 8).
Both of the benefits above are not very strong, so perhaps you just want to disable the Local variable or parameter can be final inspection. This inspection is disabled by default, so you may have enabled it by accident?
Upvotes: 3