My question is why static member variable is used in singleton
pattern?
In my project there is one class called as IDMConfig.The code of it is as follows.
public class IDMConfig {
private static IDMConfig obj;
private IDMConfig() {
init();
}
private void init(){
System.out.println("init method");
}
public static IDMConfig getInstance() {
if (obj == null)
obj = new IDMConfig();
return obj;
}
}
Object of IDMConfig is called from various classes in application like the following
IDMConfig.getInstance();
but init method which is called inside constructor..This method is only calling at the first time.If we logout the application and login then also this method is not calling?? and if we do the restart of websphere then only this method is calling next time.Can anybody explain me why this might be happening?
why member variable here is declared as static ?what is the use of this?