pt.output(12,12);
pt.output();
}
}
pt.output(12,12);
pt.output();
}
}编译运行:

我们可以利用this关键字,在不带参数的构造方法中调用带参数的构造方法,如下程序:

class Point...{
int x,y;
Point(int a,int b)...{
x=a;
y=b;
}
Point()...{
this(25,25); //在不带参数的构造函数中,用this调用带参数的构造函数
}
void output()...{
System.out.println(x);
System.out.println(y);
}
public static void main(String[] args)...