Understanding Java Singleton with Example
Singleton
Example
- public class Singleton {
- private static Singleton singleton = null;
- //Private Constructor
- private Singleton() {
- }
- public static Singleton getInstance() {
- if(singleton == null) {
- singleton = new Singleton();
- }
- return singleton;
- }
- }
Comments
Post a Comment