Example:
class MainClass {
public doIt() {
...
else doIt();
}
}
class SubClass extends MainClass {
@Override
public doIt() {
super.doIt();
...
}
}
Now the problem is:
- I call SubClass.doIt()
- MainClass.doIt() is called
- MainClass.doIt() makes recursion calling doIt()
But: the SubClass.doIt() is called instead of MainClass.doIt()
That is very strange behaviour and problems are programmed! I tried to call the recursion with this.doIt() but that didn't help. Someone has an idea?
Thanks alot for your answers, this problem is solved.
else doIt()
is same aselse this.doIt()
butthis
refers to current instance, and thanks to dynamic-binding (polymorphism mechanism) code from method of class closest to current type ofthis
is called. Since closest class toSubClass
containingdoIt
isSubClass
itself this code is invoked. – Osteotome