This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
the class can not be instantiated from outside. But it could be useful invoking it from inside: because sometimes only an instance of a class is needed a static method can invoke the constructor only once.
private/protected constructors are very important and they are useful in many ways in OOP. Many of the Java classes use them, the idea is to have greater control on 'how a new instance will be created', the ones having such constructors typically have factory methods (you may want to read book - Design Patterns) to create an instance. One class I can think of now which has such a constructor is URLConnection, among many others. You can't do new URLConnection(), but can get a reference to it by method openConnection() of URL class. [This message has been edited by Manish Hatwalne (edited September 22, 2001).]
Joined: Aug 28, 2001
Speaking of patterns, private constructors are also useful in creating Singletons.
I am sorry that I was not clear in my previous message. I was only correcting the terminology, not actually stating that the class cannot be instantiated. Of course the class can instantiate itself.