We use Builder pattern when:
- Too many constructor arguments(i.e. more than three).
- The constructor overloading can lead to incorrect object state.
- We need of flexible API.
- We want to add new parameters to a constructor without producing error-prone and hard to read code.
Calendar cal = new Calendar.Builder()
.setCalendarType("iso8601")
.setWeekDate(2013, 1, MONDAY)
.build();
Locale loc = new Builder()
.setLanguage("sr")
.setScript("Latn")
.setRegion("RS")
.build();