SyntaxHighlighter JS

2013-01-16

Singleton Pattern: Best Java implementation

For Java 5 and beyond, the best singleton implementation is using enum.

public enum Singleton {
    INSTANCE;

    public void doStuff() { ... }

}

To use the singleton


    Singleton.INSTANCE.doStuff();

No comments:

Post a Comment