this(x)构造器被类内其他构造器调用

public class Demo {
  private int x;
  private String string;
  public Demo(int x) {
  this.x = x;
}
  public Demo(int x,String string){
    this(x); //一个类的构造器调用这个类中的其他构造器
    this.string=string;
  }
}

 

 关于一个类的构造器能不能调用这个类中的其他构造器?

猜你喜欢

转载自www.cnblogs.com/yz123/p/11914119.html
今日推荐