package dptt;
public class Student {
private String name;
private String sex;
private String age;
private String mobile;
private String cname;
public String getName() {
return name;
}
public String getSex() {
return sex;
}
public String getAge() {
return age;
}
public String getMobile() {
return mobile;
}
public String getCname() {
return cname;
}
public static class Bulider{
private String name;
private String sex;
private String age;
private String mobile;
private String cname;
public Bulider(String name){
this.name = name;
}
public Bulider sex(String sex){
this.sex = sex;
return this;
}
public Bulider age(String age){
this.age = age;
return this;
}
public Bulider mobile(String mobile){
this.mobile = mobile;
return this;
}
public Bulider cname(String cname){
this.cname = cname;
return this;
}
public Student bulid(){
return new Student(this);
}
}
private Student(Bulider bulider){
name = bulider.name;
sex = bulider.sex;
age = bulider.age;
mobile = bulider.mobile;
cname = bulider.cname;
}
}
Student student = new Student.Bulider("zhangshan").age("20").sex("男")
.cname("").mobile("18682221111").bulid();