package com.heavan.test; public class ExceptionTest { public static boolean a() { try { throw new Exception(); } catch (Exception e) { System.out.println("bbbb"); return false; } finally { System.out.println("aaa"); } } public static int b() { int i = 1; try { throw new Exception(); } catch (Exception e) { return i; } finally { i++; } } /** * 輸出結果爲: */ public static void main(String[] args) { // System.out.println(a()); // System.out.println(b()); try { badMethod(); System.out.println("a"); } catch (Exception e) { System.out.println("B"); } finally{ System.out.println("c"); } System.out.println("d"); } private static void badMethod() { } }