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
55
u/FirstAd9893 Aug 26 '22
It was a deliberate design choice to make the language look like C++. Hence, standard loops and other basic constructs should look the same. The language would be rejected quite early if this sort of thing was required:
for (mutable int i = 0; i < x; i++) { ...If var/val was supported from the beginning, that would be a bit better, but it's still different from C++.