考虑一个代码示例:
public Class TestClass {
private void methodToDelete(int i, String s) {
System.out.println(s + i);
}
public void anotherMethod(){
System.out.println("Do some logic");
methodToDelete(1, "1");
methodToDelete(2, "2");
System.out.println("Do some logic");
}
}
当我在 Intellij Idea 中使用“安全删除”时,我得到了要删除的方法,但调用仍然存在:
public Class TestClass {
//Method was deleted
public void anotherMethod(){
System.out.println("Do some logic");
methodToDelete(1, "1"); //stil there
methodToDelete(2, "2"); //stil there
System.out.println("Do some logic");
}
}
可以同时删除:方法声明和任何方法调用?
更新 我也可以删除方法体并使用“内联”,但可能有更优雅的解决方案吗?:)