public class TestException {public TestException() {}boolean testEx() throws Exception {boolean ret = true;try {ret = testEx1();} catch (Exception e) {System.out.println("testEx, catch exception");ret = false;throw e;} finally {System.out.println("testEx, finally; return value=" + ret);return ret;}}boolean testEx1() throws Exception {boolean ret = true;try {ret = testEx2();if (!ret) {return false;}System.out.println("testEx1, at the end of try");return ret;} catch (Exception e) {System.out.println("testEx1, catch exception");ret = false;throw e;} finally {System.out.println("testEx1, finally; return value=" + ret);return ret;}}boolean testEx2() throws Exception {boolean ret = true;try {int b = 12;int c;for (int i = 2; i >= -2; i--) {c = b / i;System.out.println("i=" + i);}return true;} catch (Exception e) {System.out.println("testEx2, catch exception");ret = false;throw e;} finally {System.out.println("testEx2, finally; return value=" + ret);return ret;}}public static void main(String[] args) {TestException testException1 = new TestException();try {testException1.testEx();} catch (Exception e) {e.printStackTrace();}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。