컴파일 순서가 객체의 멤버에 따라 다르기 때문에 발생하는 오류이다. 가장 흔한 경우는 main 메서드가 컴파일되는 시점에 정의되지 않은 메서드나 필드를 사용할 때이다.
public class Test5 {
static void findStone() { // 해당 메서드를 static으로 변경
return;
}
public static void main(String[] args) throws FileNotFoundException {
findStone();
}
}
public class Test5 {
void findStone() {
return;
}
public static void main(String[] args) throws FileNotFoundException {
Test5 t5 = new Test5(); // 자기자신의 객체를 동적으로 생성
findStone();
}
}