Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Superclass {
- ...
- public Superclass(...) {
- ... // do stuff before initializing subclass
- }
- protected void dispatch() { //method to be called directly after creating an object
- doStuff();
- ...
- }
- public abstract void doStuff();
- }
- public class Subclass extends Superclass {
- ...
- public Subclass(...) {
- super(...); //has to be the first line
- ... //assign variables etc.
- dispatch(); //has to be called after variables are assigned etc.
- }
- public void doStuff() {
- //do stuff with assigned variables etc.
- }
- }
- public abstract class Superclass {
- ...
- public Superclass(...) {
- doStuff();
- }
- public abstract void doStuff();
- }
- public class Subclass extends Superclass {
- ...
- public Subclass(...) {
- super(...); //has to be the first line
- }
- @Override
- public void doStuff() {
- //do stuff with assigned variables etc.
- }
- }
Add Comment
Please, Sign In to add comment