Saturday, May 14, 2011

Can you have a private constructor ?

Yes . See the concept of Singleton pattern.

Note that a private constructor cannot be used by any other class. Only class itself can use it.

This is used excellently to limit the number of instances, for example if you want to create a singleton.

No comments:

Post a Comment

How to check local and global angular versions

 Use the command ng version (or ng v ) to find the version of Angular CLI in the current folder. Run it outside of the Angular project, to f...