age; public UserBuilder name(String name) { this.name = name; return this; } …. public User build() { User user = new User(); user.name = this.name; user.age = this.age; return target; } } class User { String name; int age; }
} public final class UserBuilder { private String name; private int age; …. public User build() { User user = new User(); user.name = this.name; user.age = this.age; return target; } }
} public final class UserBuilder { private String name; private int age; …. public User build() { User user = new User(); user.name = this.name; user.age = this.age; return target; } } User user = new UserBuilder().age(23).name("taku").build();