//Lazy
public class Singleton {
private Singleton() {
}
private static Singleton instance;
private static Singleton getInstance(){
if(instance == null){
instance = new Singleton();
}
return instance;
}
}
//hungry
public class HSingleton{
private HSingleton(){
}
private static HSingleton hSingleton = new HSingleton();
private static HSingleton getInstance(){
return hSingleton;
}
}