Saturday, October 29, 2016

How to create a Singleton class

Q)What is a singleton class?

A)In simple words,  A singleton class is a class which can have only one instance at any point of time throughout the application and provides a global point of access to its instance.

Q)Ok, How can you create a singleton class?

A)
class Singleton {
       public static final Singleton INSTANCE = new Singleton();

       private Singleton() {
       }
}

                 This is a simple example for a singleton class where I used a public static final INSTANCE variable and