我是 Java 编程新手,但有一些基本的了解。这是我的问题,我有一个基类,许多类扩展了这个基类。在某些情况下,在基类方法执行标准操作之后,我只需要对某些子类执行一些操作。所以我只是按照以下方式完成。只是想根据 OOPS 检查我是否正确
class BaseClass {
public void deleteThisRecord() {
// All standard code goes here
doSomethingAfterDelete(); // call clean up method after sucessful delete
}
public void doSomethingAfterDelete() {
// Nothing is here, let the sub class override this if there is need
}
}
class OneClass extends BaseClass {
// other methods
@Override
public void doSomethingAfterDelete() {
// do some action after delete
}
}