poornima
poornima

Reputation: 23

Singleton design pattern. Should its instance be public or private?

Is it necessary for instance of singleton design pattern to be private or public to be considered a singleton design pattern . for example

class Singleton { public static Singleton obj;

is the access modifier neccessary. What difference does it make.

Upvotes: 1

Views: 196

Answers (1)

Kris_WU
Kris_WU

Reputation: 1

In my view it's necessary for the instance of a singleton design pattern to be private, because somebody may Singleton.obj when it's not be initialized, it is dangerous

Upvotes: 0

Related Questions