Java Jirawat
Jirawat Uttayaya Tech Notes
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
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment