Here is a program illustrating the Singleton Pattern.
Only one instance of an object is needed throughout the lifetime of an application. The Singleton class is instantiated at the time of first access The Singletons are often used to control access to resources such as database connections or sockets. Suppose we have a license for only one connection for our database. A Singleton connection object makes sure that only one connection can be made at any time.
The following example is using a private constructor and a static method to create and return an instance of the class is a popular way for implementing Singleton Pattern.
Design Patterns
Elements of Reusable Object-Oriented Software
by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides.