Extending an abstract class - implementing abstract methods
Greetings and salutations!
I currently have an abstract class A, and many classes subclassing it. The
code common to all the subclasses I've put in the oneMethod() and the code
that's specific to each implementation I've put into two abstract methods.
public abstract class AbstractA {
public oneMethod() {
//do some intelligent stuff here
abstractMethodOne();
abstractMethodTwo();
}
protected abstract void abstractMethodOne();
protected abstract void abstractMethodTwo();
}
I have a class that overwrites the oneMethod() method.
public class B extends AbstractA {
@Override
public oneMethod() {
//do some other intelligent stuff here
}
}
is there any way to skip making a stub implementation of the two abstract
methods in the subclass? I mean the only place they're used is in the
overridden method.
Any help is appreciated!
No comments:
Post a Comment