Java Builder pattern comes under creational pattern and it provides simple way of creating complex objects.
Here is one scenario, i have a Customer class and while creating object need to pass multiple parameters. Some of these parameters are mandatory and some of them are optional. The optional parameters and i do not want to pass null values all the times and it should take the default null values.
See how builder pattern work for this scenario.
1. Create a Customer Class
Customer class will have one static nested class , which will help us to set the mandatory and optional values.