<PRE>
class Child extends Parent
{
{
System.out.println("init bloc in Child");
}
Child()
{
this(7);
System.out.println("Inside Child()");
}
Child(int i)
{
super(i);
System.out.println("Inside Child(int i)");
}
public static void main(
String args[] )
{
Child c = new Child();
}
static
{
System.out.println("static init in Child");
}
}
class Parent
{
{
System.out.println("init bloc in Parent");
}
Parent()
{
System.out.println("Inside Parent()");
}
Parent(int i)
{
System.out.println("Inside Parent(int i)");
}
static
{
System.out.println("static init in Parent");
}
}
</PRE>
Result:
static init in Parent
static init in Child
init bloc in Parent
Inside Parent(int i)
init bloc in Child
Inside Child(int i)
Inside Child()
I've been reading the archives and I saw a program similar to this. I got confused because "this" and "super" are inside the Child constructors. Does this mean that if "this" will eventually lead you to a parent constructor it will be executed first. And when the constructors inside the Child class are called they will still execute "this" then "super" except they will no longer lead to the parent class. I hope you understand what I'm saying. Can you please give me a better explanation.
Thanks in advance.
panday