Alex Rivera | Logout

How do I prevent Eclipse from adding the 'final' keyword to a member variable declaration?

Asked 2011-08-22T12:12:09.980
20

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?

Edit
Report

1 Answer

11

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; }

answered 2012-06-26T22:33:50.723

Your Answer