Program to implement Singleton Design Pattern in java with a simple program
package com.hubberspot.singleton;
public class Singleton {
private static Singleton singleInstance;
private Singleton() {}
public static synchronized Singleton getInstance() {
if (singleInstance == null) {
singleInstance = new Singleton();
}
return singleInstance;
}
@Override
protected Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
}