Skip to content

Instantly share code, notes, and snippets.

@LNA
Created February 24, 2015 22:13
Show Gist options
  • Save LNA/c6f662ffeae9ea3d36f9 to your computer and use it in GitHub Desktop.
Save LNA/c6f662ffeae9ea3d36f9 to your computer and use it in GitHub Desktop.
private class CarBuilder {
private int year;
private String make;
public CarBuilder setYear(int year) {
this.year = year;
return this;
}
public CarBuilder setMake(String make) {
this.make = make;
return this;
}
public Car build() {
return new Car(year, make);
}
}
private class Car {
private final String make;
private final int year;
public Car(int year, String make) {
this.year = year;
this.make = make;
}
}*/
/* Car car = new CarBuilder()
.setYear(2012)
.setMake("Honda")
.build();*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment