When I type this
private MyKlass myklass;
and hit 'save' in Eclipse, it becomes this:
private final MyKlass myklass;
How do I stop Eclipse from doing this?
When I type this
private MyKlass myklass;
and hit 'save' in Eclipse, it becomes this:
private final MyKlass myklass;
How do I stop Eclipse from doing this?
You need to disable that option in your 'save actions'.
right click your project > properties, then go to java editor > save actions. go to 'configure', 'code style' tab, and you have it on the bottom ('private fields').
Window - Preferences - Java - Editor - Save Actions - Configure... - Code Style - Use modifier final when possible
The same option can be found in Java - Code Style - Clean up.
If you want to leave this feature enabled in general but turn it off for a specific field, I found a simple workaround. Just declare a protected method that assigns to this field.
protected void preventFinal() {
field = null;
}
You can go to Project --> Properties --> Java Editor --> Save actions , Uncheck "Enable project specific settings"
There is Section called Save Actions in Eclipse Window -> Preferences -> Java -> Editor. There You can Configure Aditional actions - > (tab) code style - > Variable declarations -> edit use of final keyword.
Initialize the field with null
:
private File tempDir = null;
© 2022 - 2024 — McMap. All rights reserved.