心猛虎_细细闻玫瑰
正确的调用方法是直接在this ()中调用构造函数。 代码:类student {
字符串id
字符串名称;
字符串sex;
//创建构建方法
publicstudent(stringid,Stringname,StringclassNum,Stringsex,intage ) {
this(id,name,classNum,sex );
this.age=age;
}
//重载结构方法有两个参数
公共student (stringid,Stringname ) {
this.name=name;
this.id=id;
}
//重载结构方法有三个参数
公共student (stringid,Stringname,Stringsex )。
this(id,name );//在3个各参数的结构方法中调用2个参数的结构方法this(id,name )
this.sex=sex; //添加其他参数,实现构造方法调用构造方法
}
publicstaticvoidmain (string [ ] args ) {
}
}