Calling another constructor from constructor

  • Thread starter Thread starter dodger_web
  • Start date Start date
D

dodger_web

Hi,

Is there a way to call a constructor from a constructor ?

let's say i have this class :

public class Dot {

private int x;
private int y;

public Dot() {
}

public Dot(int xcoord) {
x= xcoord;
}

}

Is there a way that i can add this kind of constructor :

public Dot(int xcoord, ycoord) {

private Dot mydot = new Dot(xcoord);

mydot.y = ycoord;

return mydot;

}
 
Back
Top