A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Refactoring for Software Design Smells: Managing Technical Debt
this week in the
OO, Patterns, UML and Refactoring
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.
Have you checked out
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