The Singleton's purpose is to control object creation, limiting the number of obejcts to one only. Since there is only one Singleton instance, any instance fields of a Singleton will occur only once per class, just like static fields. Singletons often control access to resources such as database connections or sockets.
We can make constructor as private. So that We can not create an object outside of the class. This property is useful to create singleton class in java. Singleton pattern helps us to keep only one instance of a class at any time. The purpose of singleton is to control object creation by keeping private constructor.
Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!