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.StringBuffer.append(): StringBuffer is similar to StringBuilder and it is also based on Builder design pattern.