I thought that super();
means almost the same as we call the superclass constructor, but it doesnt.
class A {
A() {
foo();
}
void foo() {
System.out.print("A");
}
}
class B extends A {
void foo() {
System.out.print("B");
}
B() {
super();
super.foo();
}
}
When I call new B();
it prints BA
why? I was debuging it and super()
call constructor of A
but it prints B
(this is what Im not understanding), and why after this super.foo()
prints A
as it should. Can someone explain how does it works?