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");
}
}
Dans ce programme, une erreur StackOverflowError se produit mais est gérée et le programme ne se termine pas anormalement. Pourquoi? Vous pouvez le voir à http://ideone.com/vwSavUne erreur peut-elle être gérée?
liés: http://stackoverflow.com/questions/ 2535723/try-catch-on-stack-overflows-in-java – Thilo