lundi 8 février 2021

Why cannot a Singleton Java class be converted to a java class with only statics in it?

for singleton design pattern(gang of four), given a singleton instance is only 1 copy in memory, how is this different to a java class with all fields/methods static and with a private constructor. i.e. why is that singleton design pattern neccesary? If i make a java class with all fields/methods/static and a private constructor, it does the same thing as the singleton instance.

Aucun commentaire:

Enregistrer un commentaire