File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Constructors in a class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Constructors in a class" Watch "Constructors in a class" New topic

Constructors in a class

Ravi Hyd

Joined: Jun 27, 2005
Posts: 4
I want to know whether we can create a Private default constructor in a class. Can anybody explain what is Singleton class?
Manuel Moons
Ranch Hand

Joined: Mar 05, 2002
Posts: 229
Yes, it is possible to create a private default Constructor.

If all constructors are private you cannot create an instance from outside that class.

If you create a public static method that always returns the same instance of that class you have used the singleton pattern.

Look at the example:

I agree. Here's the link:
subject: Constructors in a class
jQuery in Action, 3rd edition