8 ms·
Enum version: public enum Singleton { INSTANCE; } Guaranteed against multiple instantiation. Edit: the class version of the singleton example
by dteoh 15y ago
Enum version:
public enum Singleton {
INSTANCE;
}
Guaranteed against multiple instantiation.
Edit: the class version of the singleton example should also be made final, or I could just extend your class and therefore bypass your singleton restriction.
- SoftwareMaven 15y agoNot with a private constructor.