How singleton pattern works in java

Singleton pattern is a design solution where an application wants to have one and only one instance of any class, in all possible scenarios without any exceptional condition. There are several ways to implement the singleton pattern. The following sections will give an idea how singleton pattern is implemented.