What is the use of private constructor in Java?
A private constructor is used when there is no requirement of another class to invoke that. It is used mostly in implementing singletons. A static method is used for managing the creating the instances of that class.
The following is the example of private constructor. public class Singleton
{
private static Singleton instance;.
//private constructor
private Singleton
{
// some code goes here
}
}