A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
REST with Spring (video course)
this week in the
Programmer Certification (SCJP/OCPJP)
Why are constructors declared private. Also is there any other way to achieve this
Joined: Feb 07, 2001
Jan 25, 2003 08:20:00
Why should this be done? How can declaring a constructor private make it have only instance?
Author and all-around good cowpoke
Joined: Mar 22, 2000
Jan 25, 2003 10:22:00
When all constructors are private, you can only get an instance through a static method of the class. That static method can manage a pool of instances or ensure that only one instance is created.
I agree. Here's the link:
subject: Why are constructors declared private. Also is there any other way to achieve this
access control modifier for enum
question about abatract
Private Constructor trap
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015