爷的眼睛闪亮
insideDotNet En_summerGarden
public class Student {

public Student(){

}

protected Builder builder(){
return new Builder();
}

public class Builder{

private String name;

private String hoby;

private int age;

public String getName() {
return name;
}

public Builder setName(String name) {
this.name = name;
return this;
}

public String getHoby() {
return hoby;
}

public Builder setHoby(String hoby) {
this.hoby = hoby;
return this;
}

public int getAge() {
return age;
}

public Builder setAge(int age) {
this.age = age;
return this;
}

@Override
public String toString() {
return "name:"+this.getName()+" age:"+this.getAge()+" hoby:"+this.getHoby();
}
}
}

public class LinkTest {

public static void main(String[] args){
Student student=new Student();
System.out.println(student.builder().setAge(10).setHoby("play basketball").setName("austin").toString());
}

}


posted on 2017-12-25 15:38  爷的眼睛闪亮  阅读(361)  评论(0编辑  收藏  举报