java4all@1986 java. Powered by Blogger.

Where and How you can use private Constructor?

>> Monday, May 30, 2011

Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing.
The instantiation is done by a public static method within the same class.
Used in the singleton design pattern. Used in the factory method design pattern e.g. java.util.Collections class .
Used in utility classes e.g. StringUtils etc.

0 comments:

Post a Comment

FaceBook Login

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

Total Pageviews

STATCOUNTER

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP