It might be that some of them are available but not obvious to me, ignore them. Some of them are minor inconveniences but do hurt productivity.
public class Sample {
public void method1(String str) {
String newStr = str + "_abc";
// Do something on newStr.
}
public void method2(String anotherStr) {
String anotherNewStr = anotherStr + "_abc";
// Do something else on anotherNewStr.
}
}
After Refactoring:
public class Sample {
public void method1(String str) {
String newStr = addSuffix(str);
// Do something on newStr.
}
public void method2(String anotherStr) {
String anotherNewStr = addSuffix(anotherStr);
// Do something else on anotherNewStr.
}
private String addSuffix(String anotherStr) {
return anotherStr + "_abc";
}
}
In Eclipse, both
str + "_abc" fragments are replaced in a single "Extract Method" refactoring. But Netbeans replaces only the location from which you initiated the refactoring leaving out the other.