Design Patterns in Java Standard Libraries
Study how core Java libraries apply familiar patterns so you can recognize design choices already embedded in the JDK.
In this section
- Java Singleton Pattern in Runtime and Logger APIsExplain how `Runtime` and logger singletons work and what trade-offs they introduce.
- Java Decorator Pattern in I/O Streams for WrappingExtend I/O stream behavior with decorators instead of subclassing.
- Iterator Pattern in Java Collections FrameworkShow how the Iterator pattern works inside the Java Collections Framework and why it matters.
- Java Strategy Pattern with Comparator SortingUse `Comparator` to switch sorting behavior at runtime without changing the calling code.
- Java Factory Patterns in JDBC Connection APIsUse factory-style JDBC APIs to keep database creation flexible and explicit.
- Java Prototype Pattern with Object Cloning Trade-OffsUse cloning, shallow copies, and deep copies to implement the Prototype pattern safely.
- Java Template Method Pattern in Abstract ClassesDefine algorithm skeletons in abstract classes and customize selected steps in subclasses.
Revised on Wednesday, June 3, 2026