Since Java 1.5, there is a new approach to implement Singletons. Simply make it an enum type :
public enum MySingleton { INSTANCE; //Singleton method public void someMethod( ) {...} }Accessing the enum singleton :
MySingleton.INSTANCE.someMethod( );
No comments:
Post a Comment