public class Employee { private String name; private String city; private double salary; private Employee() {} public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; } @Override public String toString() { return "Employee{" + "name='" + name + '\'' + ", city='" + city + '\'' + ", salary=" + salary + '}'; } public static class EmployeeBuilder { private Employee employee; public EmployeeBuilder() { this.employee = new Employee(); } public EmployeeBuilder setName(String name) { employee.name = name; return this; } public EmployeeBuilder setCity(String city) { employee.city = city; return this; } public EmployeeBuilder setSalary(double salary) { employee.salary = salary; return this; } public Employee build() { return employee; } } }