The Singleton design pattern provides a solution:
Hide the constructor of a class,
and define a static operation (getInstance())
that returns the sole instance of the class.
Describing the Singleton
design in more detail is the theme of the following sections.
See Applicability section for all problems Singleton can solve.
getInstance())
that returns the sole instance of the class.
getInstance()
is declared public and static.
Singleton.getInstance().