用java定义一个类,包含四个属性,三个构造函数(有参,无参,默认),一个对象!
用java定义一个类,包含四个属性,三个构造函数(有参,无参,默认),一个对象!(急!!!!)...
用java定义一个类,包含四个属性,三个构造函数(有参,无参,默认),一个对象!
(急!!!!) 展开
(急!!!!) 展开
展开全部
//默认的构造函数就是无参构造函数。还有对象 只能去其他的 类实例化
//这样实例化 Student stu=new Student(1,"张三","男","13108762347");
public class Student {
private int id;
private String name;
private String sex;
private String phone;
public Student() {
super();
}
public Student(int id, String name, String sex, String phone) {
super();
this.id = id;
this.name = name;
this.sex = sex;
this.phone = phone;
}
}
//这样实例化 Student stu=new Student(1,"张三","男","13108762347");
public class Student {
private int id;
private String name;
private String sex;
private String phone;
public Student() {
super();
}
public Student(int id, String name, String sex, String phone) {
super();
this.id = id;
this.name = name;
this.sex = sex;
this.phone = phone;
}
}
追问
谢谢亲
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询