I have a followup question to the one asked here:
Java Abstract Class (this keyword)
Using the following code:
public class SuperClass() {
boolean isDoneLoading = false;
ArrayList items;
public SuperClass() {
loadData();
items = new ArrayList();
}
protected void loadData() {
// loadData is a class that requests data from remote server, populates "items"
// and then calls doneLoading when done;
}
protected void doneLoading() {
isDoneLoading = true;
}
}
public class ExtendedClass extends SuperClass {
public ExtendedClass() {
super();
}
protected void doneLoading() {
// how can I get THIS method to be called when the super's doneLoading is called?
}
}
// some other class
new ExtendedClass();
How can I get the “child’s” (ExtendedClass) doneLoading() class when the super’s doneLoading class is called?
If you want the parent
doneLoadingfollowed by the childs version of the routine, and yet retain this functionality in the parent, they must be named differently. E.g.,The other option delegates the responsibility to the child to invoke
super.doneLoading().