this(.....)

what does this mean:this(new Point(0,0), w, h);what does the "this()" do?
[101 byte] By [-zah-a] at [2007-10-1 1:35:35]
# 1
Double-post.
annie79a at 2007-7-8 1:55:37 > top of Java-index,Security,Event Handling...
# 2

this(....) calls another consteuctor in the same class with different parameters (some people refer to this as "chained constructors").

For example, you have a Square class that needs 3 basic parameters: x,y, and length (length would be the width and the height, cuz it's a square)

Just to keep things easy though, you want to provide a constructor that defaults x and y to 0, so all you would have to specify is length. You could use chainged constructors for this:

public class Square {

int x,y,length;

public Square(int length) {

// default x and y to 0

this(0,0,length);

}

public Square(int x,int y, int length) {

this.x = x;

this.y = y;

this.length = length;

}

}

Woogleya at 2007-7-8 1:55:37 > top of Java-index,Security,Event Handling...