What is a Singleton Class?

A singleton is a class that allows only a single instance of itself to be created and gives access to that created instance. It contains static variables that can accommodate unique and private instances of itself. It is used in scenarios when a user wants to restrict instantiation of a class to only one object. This is helpful usually when a single object is required to coordinate actions across a system.
 
Singelton class is a class whose object can be created only once, i.e. which can have only one instance. That one instance will be used in the entire application.
 
In object-oriented programming, a singleton class is a class that can have only one object (an instance of the class) at a time.Creating multiple objects of java class having same data is wasting memory, degrading performance.singleton class is recommended to create one object and use it multiple times.
 
Last edited:
Back
Top