public class Person {
String name;
public Person(){
}
public Person(String name){
this();//注意不是 this.Person(),该调用语句必须放在第一个语句
this.name = name;
/*
* Constructor call must be the first statement in a constructor
*/
//this();//报错
}
}
最后
以上就是瘦瘦板凳最近收集整理的关于java 调用另一个构造器的全部内容,更多相关java内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复