public class Foo {
public static void main(String[] args) {
foo();
}
public static void foo() {
try {
System.out.println("try");
foo();
} catch (Throwable e) {
System.out.println("catch");
foo();
} finally {
System.out.println("finally");
foo();
}
}
}
誰能解釋這段代碼的輸出?java try-catch-finally遞歸問題
1.輸出基於Eclipse(無盡的)客戶端模式:
try try .... ... ... tryfinallyfinally tryfinallyfinally try try try tryfinallyfinally tryfinallyfinally try tryfinallyfinally tryfinallyfinally try .... ....
在Linux 2.輸出(崩潰)服務器模式:
try try ... ... try try try try try try MISSING EXCEPTION HANDLER for pc 0x00002aaaab1c53f0 and handler bci -1 Exception: Compiled exception table : ExceptionHandlerTable (size = 3304 bytes) catch_pco = 700 (1 entries) bci -1 at scope depth 0 -> pco 11039 catch_pco = 1736 (1 entries) bci -1 at scope depth 0 -> pco 11473 catch_pco = 1756 (1 entries) bci -1 at scope depth 0 -> pco 11433 catch_pco = 1776 (1 entries)
***誰能解釋這段代碼的輸出?***:可能是**你**。你運行這個時得到了什麼? –
...計算器 – MarcoS
輸出確實是意外: 嘗試 嘗試 嘗試 tryfinallyfinally tryfinallyfinally 嘗試 tryfinallyfinally tryfinallyfinally 嘗試 嘗試 tryfinallyfinally tryfinallyfinally 嘗試 tryfinallyfinally tryfinallyfinally 嘗試 嘗試 嘗試 試 –