try catch嵌套try catch
try { //A int a = 3 / 0; /** * E Exception * F 外层finally */ try { //B int b = 3 / 0; /** * 注释掉A * C Exception * D 内层finally * F 外层finally */ } catch (Exception ex) { //C System.out.println("C Exception"); } finally { //D System.out.println("D 内层finally"); } } catch (Exception ex) { //E System.out.println("E Exception"); } finally { //F System.out.println("F 外层finally"); }
1、执行后:
E Exception
F 外层finally
2、注释掉A处代码
C Exception
D 内层finally
F 外层finally