I am a one and half year experienced java developer. My question is :What is singleton? It seems that I never use it in my project(Java web,Spring boot ). I just cannot understand why and when should I use singleton. Sorry guys ,let me explain my confusion. A simple singleton class look like this:
class Singleton {
private static Singleton instance;
private Singleton(){
}
public static Singleton getInstance(){
if(instance=null){
instance=new Singleton();
}
return instance;
}
........
}
Looks like there is not difference when I want to new a singleton object: Singleton s = new Singleton();