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 –