public class Flower{
int i;
Flower (int petals){}
Flower(String ss){}
Flower(int petals, String ss){
//petals++;调用另一个构造函数的语句
this(this.i);
//this(this.i);会产生错误 this(ss); //this(ss);会产生错误,因为在一个构造函数中只能调用一个构造函数
}
}
int i;
Flower (int petals){}
Flower(String ss){}
Flower(int petals, String ss){
//petals++;调用另一个构造函数的语句
this(this.i);
//this(this.i);会产生错误 this(ss); //this(ss);会产生错误,因为在一个构造函数中只能调用一个构造函数
}
}
{
int i;
Flower(int petals) { }
Flower(String ss) { }
Flower(int petals, String ss):this(petals)//调用签名是int类型的构造函数
{
}
Flower()
: this("")//调用构造函数是字符串的构造函数
{ }
}
函数里this是指向当前的实例,是已经创立了的对象
至于在构造函数里调用其它构造函数的方法同4楼.