Source: http://www.blogjava.net/flustar/archive/2007/12/03/builder.html
Builder mode definition: separates the construction of a complex object from its representation, so that different representations can be created during the same construction process. When I first came into contact with this model, I really couldn't understand what it meant and what's the use of it. As a result, the Internet Googled and finally got the universally accepted explanation: the construction mode is to create a complex object step by step, it allows users to build complex objects by specifying the types and content of complex objects. users do not know the specific internal building details. The following example shows how to use this mode, Code Import Java. util. arraylist; interface builder {public void buildparta (); Public void buildpartb (); Public void buildpartc (); Public Product getproduct ();} class product {private arraylist <string> parts = new arraylist <string> (); Public void add (string part) {parts. add (part);} public void show () {system. out. println ("product consists of the following parts:"); For (string S: parts) {system. out. println (s) ;}} class worker imp Lements builder {private product; Public void buildparta () {Product = new product (); product. add ("Part A");} public void buildpartb () {product. add ("B Part");} public void buildpartc () {product. add ("C part");} public product getproduct () {return product;} class designer {public void Order (Builder) {builder. buildparta (); builder. buildpartb (); builder. buildpartc () ;}} public class test {P Ublic static void main (string [] ARGs) {designer = new designer (); Builder = new worker (); designer. order (builder); product Product = builder. getproduct (); product. show () ;}} the output result is as follows: the product consists of the following parts: part A, Part B, and part C. From this example, we can see the builder mode, the process of building objects is divided into parts. Summary: The Builder mode mainly aims to decouple the process of building complex objects from its components. So that we don't have to worry about how each part is assembled.