What is the fastest way in Intellij to refactor a java instance method to another class in terms of (refactoring) steps.
For example:
public class Bar {
public String getX(){
return "x";
}
}
public class Foo {
}
public class Runner {
public static void main(String[] args) {
new Bar().getX();
}
}
Refactor to:
public class Bar {
}
public class Foo{
public String getX(){
return "x";
}
}
public class Runner {
public static void main(String[] args) {
new Foo().getX();
}
}
Fooshould thegetXmethod be invoked on?Foodoesn't matter.new Foo()is fine or if all the instances ofFooin the program arefoothefoowould be fine too.Bar.getX()call the static methodFoo.getX(), then inline all of the calls toBar.getX().