Java Can';t在溢出构造函数中默认我的参数

Java Can';t在溢出构造函数中默认我的参数,java,Java,我不能默认我的参数,我不知道如何使用(this)语句设置数组。 我知道这听起来很愚蠢,但我从来没听说过 package try_Constructor; public class NewTry { private int[] point1; private int[] point2; private int[] point3; public NewTry(){ this(0,0, 1,0, 1,1); } publ

我不能默认我的参数,我不知道如何使用(this)语句设置数组。
我知道这听起来很愚蠢,但我从来没听说过

package try_Constructor;

public class NewTry {

    private int[] point1;
    private int[] point2;
    private int[] point3;

    public NewTry(){

            this(0,0, 1,0, 1,1);
    }

    public NewTry(int[] point1){

        this(point1, 1,0, 1,1);
    }

    public NewTry(int[] point1, int[] point2){

        this(point1, point2, 1,1);
    }

        public NewTry(int[] point1,int[] point2,int[] point3){

            setPointsOfTry(point1, point2, point3);
        }
你可以简单地做

public NewTry() { 
    this(new int[] {0,0}, new int[] {1,0}, new int[] {1,1});
}
等等

也就是说,如果要在
Java
中传递一个“常量”整数数组{0,0},只需将其作为
newint[]{0,0}
传递即可

public NewTry() { 
    this(new int[] {0,0}, new int[] {1,0}, new int[] {1,1});
}
等等

也就是说,如果要在
Java
中传递一个“常量”整数数组{0,0},只需将其作为
newint[]{0,0}
传递即可

public NewTry() { 
    this(new int[] {0,0}, new int[] {1,0}, new int[] {1,1});
}
等等

也就是说,如果要在
Java
中传递一个“常量”整数数组{0,0},只需将其作为
newint[]{0,0}
传递即可

public NewTry() { 
    this(new int[] {0,0}, new int[] {1,0}, new int[] {1,1});
}
等等


也就是说,如果您想在
Java
中传递一个“常量”整数数组{0,0},只需将其作为
newint[]{0,0}

传递即可,不要重新发明轮子。使用。此外,始终链接到下一个最具体的构造函数,而不是断开链接并跳到末尾

然后

private static final Point DEFAULT_POINT_1 = new Point(0, 0);
private static final Point DEFAULT_POINT_2 = new Point(1, 0);
private static final Point DEFAULT_POINT_3 = new Point(1, 1);

public NewTry() {
    this(DEFAULT_POINT_1);
}

public NewTry(Point point1) {
    this(point1, DEFAULT_POINT_2);
}

public NewTry(Point point1, Point point2) {
    this(point1, point2, DEFAULT_POINT_3);
}

public NewTry(Point point1, Point point2, Point point3) {
    this.point1 = point1;
    this.point2 = point2;
    this.point3 = point3;
}

不要重新发明轮子。使用。此外,始终链接到下一个最具体的构造函数,而不是断开链接并跳到末尾

然后

private static final Point DEFAULT_POINT_1 = new Point(0, 0);
private static final Point DEFAULT_POINT_2 = new Point(1, 0);
private static final Point DEFAULT_POINT_3 = new Point(1, 1);

public NewTry() {
    this(DEFAULT_POINT_1);
}

public NewTry(Point point1) {
    this(point1, DEFAULT_POINT_2);
}

public NewTry(Point point1, Point point2) {
    this(point1, point2, DEFAULT_POINT_3);
}

public NewTry(Point point1, Point point2, Point point3) {
    this.point1 = point1;
    this.point2 = point2;
    this.point3 = point3;
}

不要重新发明轮子。使用。此外,始终链接到下一个最具体的构造函数,而不是断开链接并跳到末尾

然后

private static final Point DEFAULT_POINT_1 = new Point(0, 0);
private static final Point DEFAULT_POINT_2 = new Point(1, 0);
private static final Point DEFAULT_POINT_3 = new Point(1, 1);

public NewTry() {
    this(DEFAULT_POINT_1);
}

public NewTry(Point point1) {
    this(point1, DEFAULT_POINT_2);
}

public NewTry(Point point1, Point point2) {
    this(point1, point2, DEFAULT_POINT_3);
}

public NewTry(Point point1, Point point2, Point point3) {
    this.point1 = point1;
    this.point2 = point2;
    this.point3 = point3;
}

不要重新发明轮子。使用。此外,始终链接到下一个最具体的构造函数,而不是断开链接并跳到末尾

然后

private static final Point DEFAULT_POINT_1 = new Point(0, 0);
private static final Point DEFAULT_POINT_2 = new Point(1, 0);
private static final Point DEFAULT_POINT_3 = new Point(1, 1);

public NewTry() {
    this(DEFAULT_POINT_1);
}

public NewTry(Point point1) {
    this(point1, DEFAULT_POINT_2);
}

public NewTry(Point point1, Point point2) {
    this(point1, point2, DEFAULT_POINT_3);
}

public NewTry(Point point1, Point point2, Point point3) {
    this.point1 = point1;
    this.point2 = point2;
    this.point3 = point3;
}

这是指类,在本例中是指Newtry。由于这些数组是类的字段,因此必须在构造函数中依次引用它们:

    public Newtry(){
      this.p1 = {1,2,3...};
      this.p2 = {3,4,5...};
      this.p3 = {6,7,8...};
    }

这是指类,在本例中是指Newtry。由于这些数组是类的字段,因此必须在构造函数中依次引用它们:

    public Newtry(){
      this.p1 = {1,2,3...};
      this.p2 = {3,4,5...};
      this.p3 = {6,7,8...};
    }

这是指类,在本例中是指Newtry。由于这些数组是类的字段,因此必须在构造函数中依次引用它们:

    public Newtry(){
      this.p1 = {1,2,3...};
      this.p2 = {3,4,5...};
      this.p3 = {6,7,8...};
    }

这是指类,在本例中是指Newtry。由于这些数组是类的字段,因此必须在构造函数中依次引用它们:

    public Newtry(){
      this.p1 = {1,2,3...};
      this.p2 = {3,4,5...};
      this.p3 = {6,7,8...};
    }

你想在默认构造函数中做什么?“never been with words”显然他想用3个参数将默认值传递给第4个(“full”)构造函数。只是制作一个溢出构造函数来固定3个数组,但我不能使用(this)语句来设置构造函数的数组/参数。所以,如果我不给object/“我不知道,构造函数”所有参数,它会自动设置它们。如果这对你有意义的话。你在默认构造函数中尝试做什么?“从未使用过单词”显然,他试图用3个参数将默认值传递给第4个(“完整”)构造函数。只是制作一个溢出的构造函数来固定3个数组,但我不能使用(this)语句来设置构造函数的数组/参数。所以,如果我不给object/“我不知道,构造函数”所有参数,它会自动设置它们。如果这对你有意义的话。你在默认构造函数中尝试做什么?“从未使用过单词”显然,他试图用3个参数将默认值传递给第4个(“完整”)构造函数。只是制作一个溢出的构造函数来固定3个数组,但我不能使用(this)语句来设置构造函数的数组/参数。所以,如果我不给object/“我不知道,构造函数”所有参数,它会自动设置它们。如果这对你有意义的话。你在默认构造函数中尝试做什么?“从未使用过单词”显然,他试图用3个参数将默认值传递给第4个(“完整”)构造函数。只是制作一个溢出的构造函数来固定3个数组,但我不能使用(this)语句来设置构造函数的数组/参数。所以,如果我不给object/“我不知道,构造函数”所有参数,它会自动设置它们。如果你觉得有道理的话。