What are the examples of Builder design pattern in JDK?

In JDK there are many places where Builder design pattern is used. Some of these are as follows:

  • java.lang.StringBuilder.append(): StringBuilder is based on Builder pattern.
  • java.nio.IntBuffer.put(): Invocation of put() method return IntBuffer. Also there are many variants of this method to build the IntBuffer.
  • javax.swing.GroupLayout.Group.addComponent(): We can use addComponent() method to build a UI that can contain multiple levels of components.
  • java.lang.Appendable
  • java.lang.StringBuffer.append(): StringBuffer is similar to StringBuilder and it is also based on Builder design pattern.
Read the full book at www.amazon.com
Posted in Design Pattern, Design Pattern Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*