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 use the final keyword in a method declaration to indicate that the method cannot be overridden by subclasses. The Object class does this—a number of its methods are final .
Final variables If a variable is declared with the final keyword, its value cannot be changed once initialized. Note that the variable does not necessarily have to be initialized at the time of declaration. If it's declared but not yet initialized, it's called a blank final variable.
In Java, the final keyword is used to denote constants. It can be used with variables, methods, and classes. Once any entity (variable, method or class) is declared final , it can be assigned only once.
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 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