P.6. Design Patterns Used in Package java.util

In this section, we use the material on data structures and collections discussed in Chapters 1719 to identify classes from package java.util that use design patterns.

P.6.1. Creational Design Patterns

We conclude our discussion of creational design patterns by presenting the Prototype design pattern.

Prototype

Sometimes a system must make a copy of an object but will not “know” that object’s class until execution time. For example, consider the drawing program design of Exercise 10.1 in the optional GUI and Graphics Case Study—classes MyLine, MyOval and MyRect represent “shape” classes that extend abstract superclass MyShape. We could modify this exercise to allow the user to create, copy and ...

Get Java™ How to Program, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.