D
David
Hi guys,
I have two classes "Mother" and "Daughter".
Mother is an abstract class with a public method "foo()" implemented
"Daughter" extends Mother and implements a public method "foo()"
I want the foo() method from Daughter to perform some calculations then
call the implementation from "foo()" in the class Mother.
Is this possible, if yes, how please? I've tried it, but i've ended in an
infinite recursive call. Here's the dumb code:
//------------------------
abstract class Mother {
protected int x;
public void foo() {
System.out.println("x: " + x);
}
}
class Daughter extends Mother {
public void foo() {
x = 3;
((Daughter) this).foo();
}
}
public class Test {
public static void main(String[] args) {
Daughter d = new Daughter();
d.foo();
}
}
//------------------------
Fanxs for your help.
_
David Hitillambeau
I have two classes "Mother" and "Daughter".
Mother is an abstract class with a public method "foo()" implemented
"Daughter" extends Mother and implements a public method "foo()"
I want the foo() method from Daughter to perform some calculations then
call the implementation from "foo()" in the class Mother.
Is this possible, if yes, how please? I've tried it, but i've ended in an
infinite recursive call. Here's the dumb code:
//------------------------
abstract class Mother {
protected int x;
public void foo() {
System.out.println("x: " + x);
}
}
class Daughter extends Mother {
public void foo() {
x = 3;
((Daughter) this).foo();
}
}
public class Test {
public static void main(String[] args) {
Daughter d = new Daughter();
d.foo();
}
}
//------------------------
Fanxs for your help.
_
David Hitillambeau