samedi 22 juin 2019

Why does Core Java library NOT use ENUMs for implementing the Singleton pattern

The core java classes pointed by the famous BalusC answer (https://stackoverflow.com/a/2707195):

java.lang.Runtime#getRuntime()
java.awt.Desktop#getDesktop()
java.lang.System#getSecurityManager()

All the above classes seems to Classes with private constructors instead of being the Enums. If Enum was the best practice to implement a Singleton pattern (Why is Enum best implementation for Singleton), why it was not used in the core java source?

Aucun commentaire:

Enregistrer un commentaire