Somebody tell me:
class MyClass {
private static MyClass myClass = new MyClass();
private static final Object obj = new Object();
public MyClass() {
System.out.println(obj); // will print null once
}
}
I wonder, isn't this a bug? Why static objects are not initialized before the constructor runs?
--update
I'd just copied this example program without attention, I thought we were talking about 2 Object fields, now I saw that the first is a MyClass field.. :/
Accepted-answer mark goes to Pyrolistical by the dedication to explain.
Also, thanks Kevin Brock.
I thank everyone who supported, I thank the academy, the friends,.. XD