+ 6
Why to mark constructor as private in Java ?
I know the constructor in Java can be marked as private, but I don't know why to do that ? What is the purpose of private constructor ? Please provide an example.
1 Odpowiedź
+ 9
Example where you could use a private constructor: Singleton pattern.
https://www.sololearn.com/discuss/129670/?ref=app
https://www.sololearn.com/discuss/380564/?ref=app
and many more threads.