+ 1

What is singleton class??

23rd Feb 2018, 3:59 PM
Mansi Parkale
2 Answers
+ 3
Here: https://en.m.wikipedia.org/wiki/Singleton_pattern Basically Singleton pattern restricts the instantiation of a class and ensures that only one instance of the class exists in the java virtual machine. The singleton class must provide a global access point to get the instance of the class. Singleton pattern is used for logging, drivers objects, caching and thread pool.
23rd Feb 2018, 5:00 PM
Sergiu Panaite
Sergiu Panaite - avatar
+ 1
Declare the constructor "private" and boom you have a singleton class. So, basically there will be just one instance for that particular class. Or take a look at this, it is a better explanation than mine :D https://www.geeksforgeeks.org/singleton-class-java/
26th Feb 2018, 6:27 AM
vishal jamdagni
vishal jamdagni - avatar