I'm working on a Java project on NetBeans.
At some point, I have several variables and methods (say, about twenty) which are not static. I want to refactor all of them to be static. How can I proceed with that? Can netbeans do that?
Example:
public void method1() {
//...
}
public void method2() {
//...
}
When I click somewhere, or press some buttons, I want that the previous methods become:
Example:
public static void method1() {
//...
}
public static void method2() {
//...
}
All at once.
--
Another common variant: suppose that I have set all my methods to public, but I don't want it anymore. How could I refactor all the methods to be private (so later I can change to public only what I find necessary)?
One year later I've found out that this task is better accomplished with the help of a good general-purpose text-editor, such as emacs or vim, instead of IDEs (NetBeans, Eclipse, etc).
In this case, the better text editor is the one which the user is already used to, Emacs in my case. Multiple cursors package easily solves this. Another option is to use the native query-replace
function (bounded to M-%
by default).