Why it is need to declare the constructor of the class private
1- Do you really think that you would make the constructor of utility classes
e.g. java.util.Arrays or java.util.Collections
2- you are cheap and you don't want the other people to extends your class but wait a minute you can do it by making final your class
3- In normal life or you want to implements factory or singleton design pattern and you don't want the multiple instance or you want the instance of your choice and your type your child.
4- you are using inner class but want to instantiate inside your outer class only make it as private variable of your daddy class
Comments
Post a Comment