Example of Constructor Chaning
class Initemp
{
int x;
{
System.out.println("Init block executed.");
this.x=20;
}
Initemp()
{
this(10);
this.x=10;
System.out.println("Default"+x);
}
Initemp(int x)
{
this(10,20);
System.out.println(x);
}
Initemp(int x,int y)
{
System.out.println("First Execute");
}
public static void main(String...s)
{
new Initemp();
System.out.println("Vijay Prakash");
}
}
No comments:
Post a Comment