Using this with a Constructor
Note the use of "this" key word , this is an explicit way of creating
constructotr
public class My_Class
{
private int x, y;
private int width, height;
public My_Class() { this(0, 0, 0, 0); }
public My_Class(int width, int height) {this(0, 0, width, height); }
public My_Class (int x, int y, int width, int height) {
this.x = x; //here note the use of common name declared at class and
function level
this.y = y;// this.y My_Class
s to the address of private int y variable
this.width = width;
this.height = height;
}
}