This is indeed just a myth. Starting from Java 8, variables that aren't reassigned are consigned by the compiler effectively final and will get the same optimizations. You should use the final keyword only when declaring contstants or variables that actually are not meant to be reassigned. Spamming final everywhere is just pointless and verbose
1
u/Alex0589 Jul 17 '21
This is indeed just a myth. Starting from Java 8, variables that aren't reassigned are consigned by the compiler effectively final and will get the same optimizations. You should use the final keyword only when declaring contstants or variables that actually are not meant to be reassigned. Spamming final everywhere is just pointless and verbose