How to convert a local method variable or expression into a method parameter using Eclipse?

How to convert a local method variable or expression to a method parameter using the built-in Eclipse refactoring tools?

+7
java eclipse refactoring
source share
2 answers

You can use the "Enter Parameter" parameter in the "Refactor .." submenu when you right-click.

You will need to select an expression, such as the expression used to initialize the local variable for this to work.

+12
source share

If you delete the declaration of your local variable, the places where you used this variable will no longer compile. Then you can select "Add Parameter" from the quick fix menu (Ctrl-1, I think, now there is no open Eclipse).

+3
source share

All Articles