public class StaticInnerClass {
public static void main(String[] args) {
//Outers out=new Outers();
Outers.Inner1 in=new Outers.Inner2();
in.display();
}
}
class Outers
{
static class Inner1
{
static void display()
{
display();
System.out.println("Inner1");
}
}
static class Inner2 extends Inner1
{
static void display()
{
System.out.println("Inner2");
}
}
}
위의 프로그램에서 스택 오버 플로우 오류가 발생합니다. 정적 메서드가 재정의하지 않기 때문에 "Inner1"이 표시되지 않는 이유를 설명하십시오. 실행정적 내부 클래스의 정적 메서드를 재정의하는 데 Stackoverflow 오류가 발생했습니다.
당신은 재귀 적으로'display()'를 호출하고 있습니다. –