0
why constructor call must be the first statement in a constructor?
please explain this
2 Answers
0
Can you give more details..Do you mean why calling costructor inside main class before accessing the object methods
0
actually he is asking in programming while we using this key word or super key word to invoke other constructor we must call it as first statement.
ex: public Rectangle()
{ this(0,0,1,1);
// statements }
public Rectangle( int x,int y,int width,int height)
{ this.x=x;
this.y=y;
this.width=width;
this.height=height}
in the above ex Rectangle() method invokes other constructor i.e parameterized rectangle constructor