public class StackTest {
public static void main(String[] args) {
show();
System.out.print("welcome back to maain");
display();
}
static void show(){
try{
show(); //recursion
}catch(StackOverflowError e){
System.out.print("error cought");
}
}
static void display(){
System.out.print("after stack overflow error");
}
}
在这个程序中发生StackOverflowError但得到处理,程序不会异常终止。为什么? 你可以在http://ideone.com/vwSav是否可以处理错误?
(通过使用Thread.stop()触发):http://stackoverflow.com/questions/ 2535723/try-catch-on-stack-overflows-in-java – Thilo