Singelton
Singelton
Singelton
Intent
• Ensure a class only has one instance, and
provide a global point of access to it.
Motivation
• It's important for some classes to have exactly
one instance.
• Although there can be many printers in a
system, there should be only one printer
spooler .
• There should be only one file system and one
window manager.
• An accounting system will be dedicated to
serving one company
• How do we ensure that a class has only one instance and
that the instance is easily accessible?
private Singleton() {}