Search This Blog

Loading...

Saturday, March 03, 2007

Where and how can you use a private constructor?

Private constructor is used if you do not want other classes to instantiate the object. The instantiation is done by a
public static method within the same class.


1.Used in the singleton pattern..
2.Used in the factory method pattern .
3.Used in utility classes e.g. StringUtils etc.

No comments: