Hacker News new | ask | show | jobs
by dteoh 5454 days 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.

1 comments

Not with a private constructor.