Intellij Idea - automatically add final keyword to the generated variables
Go to preferences -> Code Style -> Code Generation and enable "Make generated local variables final" in the "Final modifier" section. You can also try searching for "final" in preferences.
For Windows User;
Go to File
-> Settings
-> Editor
-> Code Style
-> Select Preferred Language (Java
) -> Checkbox
-> Make generated local variables final, Make generated parameters final
-> Apply
-> OK
In IntelliJ 14.1.3
Preferences
>Editor
>Code Style
>Java
- To the far right ,there's a tab called
Code Generation
- In the section called
Final Modifier
there are two choices:- Make generated local variables final
- Make generated parameters final
After selecting "introduce local variable" there is a little gear to the right of the variable name. Click that and check "Declare final". That variable will be marked as final and Intellij will remember your preference until changed.