jeudi 2 juin 2016

Can we create a Singleton class by having non-private instanceName?

Generally, I have seen instance variables in a Singleton class being kept private. But is it possible to keep it non-private? What if we declare an instance like this:-

final static SingletonClass singletonInstance= new SingletonClass(); 

Will it cause any problem for the class being a valid Singleton class?

Aucun commentaire:

Enregistrer un commentaire