需要你在下面的代碼反饋 -捕獲的Throwable錯誤
public static void main(String[] args) {
try {
throw new OutOfMemoryError();
} catch (Exception e) {
System.out.println("Inside catch");
} catch (Throwable t){
System.out.println("Inside catch throwable");
}finally {
System.out.println("Inside finally");
}
}
在這裏,我從try子句&引發OutOfMemoryError對象(使用new操作符)捕捉Throwable對象。所以我得到了輸出「內部可拋」&「內心終於」。但是因爲我們拋出OutofMemError不應該退出代碼(即最終不會拋出Throwable &)?在實際的實際項目中,如果我們得到OutOfMemoryError,應用程序就會退出......爲什麼這種差異?
這就是爲什麼你不抓住'Throwable' – 2012-04-19 17:57:47