首页 > 学院 > 开发设计 > 正文

构建器调用构建器

2019-11-08 19:59:38
字体:
来源:转载
供稿:网友

尽管可用this 调用一个构建器,但不可调用两个,构建器调用必须是我们做的第一件事情,否则会收到编译程序的报错信息

Flower() {this("hi", 47);System.out.PRintln("default constructor (no args)");}

Flower(String s, int petals) {this(petals);this.s = s; System.out.println("String & int args");}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表