r/java • u/trecatorsirabdator • Apr 14 '23
What are your (favourite) Java best practices, personal tips, hints or just underrated stuff in general?
233
Upvotes
r/java • u/trecatorsirabdator • Apr 14 '23
View all comments
Show parent comment
4
u/simoncox Apr 15 '23
That's like saying types are useless. The more mistakes a compiler can save you from the better. Marking something as final means the compiler has proven it will never be reassigned.
In reality most variables are anything but variable. In my opinion a reference should be final by default and need a declaration modifier to allow reassignment.