Java supports this feature using ‘this’ pointer.

Example:

class sample

{

private:

int a, b;

public:

sample(int a)

{

this.a=a;

}

sample(int a, int b)

{

this(a); //calls the single parameter constructor

this.b=b;

}

}

Advertisements