public class outer {
void meth(){
System.out.println("outer");
}
outer y = new outer(){
void meth(){
System.out.println("anonymous");
}
};
public static void main(String[] args) {
outer a = new outer();
a.meth();
}
}
當上述代碼運行我得到:異常在匿名內部類例如
Exception in thread "main" java.lang.StackOverflowError
我試圖在一個單一的類來執行匿名內部類;那可能嗎? 這個例外的原因是什麼?
@hexafraction線程「main」中的異常java.lang.StackOverflowError –