What is constructor chaining in Java and how you perform?

: 158
Paper : Java FAQ (Frequently Asked Questions and answers) for freshers | Platform : Object-oriented programming Language | Category : Programming FAQs

One constructor can call another constructor of the class with respect to the current class object. Constructor chaining can be performed inside the same with the help of this keyword.  

Example:

public class student

{

int id;

String name;

public student(int id)

{

this.id=id;

}

public student(int id, String name)

{

this(id);

this.name=name;

}

public static void main(String[] args)

{

student s = new student(3, " Ram");

System.out.print("The student id" + id + "and name is" + name); 

}

}