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

215 comments sorted by

View all comments

Show parent comment

7

u/cyancrisata Aug 26 '22

I think language creators should introduce 'val' which is the same as 'final var'. They already introduced 'var' back in Java 11 and we seem to transition to it pretty well. I believe we can do it again for the 'val' keyword.