问候和问候!
我目前有一个抽象类 A,以及许多类的子类。我放在 oneMethod() 中的所有子类共有的代码,以及我放在两个抽象方法中的每个实现的特定代码。
public abstract class AbstractA {
public oneMethod() {
//do some intelligent stuff here
abstractMethodOne();
abstractMethodTwo();
}
protected abstract void abstractMethodOne();
protected abstract void abstractMethodTwo();
}
我有一个覆盖 oneMethod() 方法的类。
public class B extends AbstractA {
@Override
public oneMethod() {
//do some other intelligent stuff here
}
}
有没有办法跳过子类中两个抽象方法的存根实现?我的意思是它们被使用的唯一地方是在被覆盖的方法中。
任何帮助表示赞赏!