21

Possible Duplicate:
Examples of GoF Design Patterns

At an interview a while back I was asked for some examples of Design Patterns within the JDK.

Off the top of my head I was able to identify

Flyweight - as used in the String pool Singleton - in java.lang.Runtime Iterator - as used on Collections classes

Not that many.

What are the other good examples of Design Patterns as used in the JDK?

Community
  • 1
  • 1
Pram
  • 2,261
  • 3
  • 31
  • 50

3 Answers3

10

Observer interfaces, you have them out-of-the-box.

For a complete answer, read this: Examples of GoF Design Patterns in Java's core libraries

Community
  • 1
  • 1
pakore
  • 11,395
  • 12
  • 43
  • 62
5

Ouch, that's a tough question. Patterns are used almost everywhere in java. You can find some patterns used in Java EE on the Java BluePrints page.


Resources :

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Colin Hebert
  • 91,525
  • 15
  • 160
  • 151
3

You can try a straightforward approach: goto the JDK Javadoc and search for (Ctrl + F) the names of some design patterns. For example,

Nate W.
  • 9,141
  • 6
  • 43
  • 65