Please refer below code and help me to understand why this not a valid singleton implementation.
class A{
private static A ob;
private A(){}
static {
ob = new A();
}
public static A getInstance() {
return ob;
}
}
private A() {}private static final A ob = new A();, it is semantically identical.staticbrackets will make the code execute even if he never requires an instance of A, won't it?