3
Line 4
에서 할당 문을 실행할 때 컴파일러가 을 무시하고 foo
변수를 null로 유지하거나이 이상한 순간을 처리하는 다른 작업은 어떻게됩니까?클래스 자체에서 인스턴스 만들기
public class Foo {
// creating an instance before its constructor has been invoked, suppose the "initializing"
// gets printed in constructor as a result of the next line, of course it will not print it
private Foo foo = new Foo();//Line 4
public Foo() {
System.out.println("initializing");
}
}
어떤 일에서 내 생각 엔 .... OUT 힙 공간 –
의 나는 순서가 중요 몰랐어요. 이 코드를 사용해 보셨습니까? – BlackVegetable