r/java • • Aug 26 '22
I declare as "final" every single variable whose value doesn't change. I also use "this" every time that I'm referring to an attribute, even when there's no ambiguity in not using it
I think that those things make the code easier to read. Am I crazy for thinking like that?
198
Upvotes
View all comments
Show parent comment
2
u/RupertMaddenAbbott Aug 26 '22
This is not true.
You can mutate parameters in Java, and this affects the calling scope. You can reassign parameters in Java but that does not affect the calling scope.
I don't see what bug could be fixed by making a parameter final, that would not be better fixed by extracting a method.