In constructors I very often assign to a non-existing field and choose Ctrl+1 "Create field 'memberField' in type 'CurrentType'".
The problem is that I want the field to be final by default, which it isn't. Is there a template for this quick fix somewhere? Thanks.
I didn't see any obvious way to do that through code template, perhaps because this is not the Java language default.
While there are blog posts out there advocating for Data immutability by default, this is not the default style in use, as in has been previously debated in SO (or in many other SO questions)
However, you can modify the Cleanup process (occurring on each save if you want):
Java > Code Style > CleanUp > Code Style
and select Use modifier 'final' where possible
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With