void方法中用return可以结束方法中抛出异常,如果没有在自己的方法中捕捉,将中断方法 代码: public class TestThrow { /** * @param args * @throws Exception */ public static void main(String[] args) { try { foo1(); foo2(); foo3(); } catch (Exception e) { System.out.println("something wrong!"); } } /** * foo1 用ruturn返回,后面代码不再执行 */ public static void foo1() { int a = 1; if (a == 1) { return; } /* */ System.out.println("foo1"); } /** * foo2 方法自己捕获异常 */ public static void foo2() { Exception e = new Exception(); int a = 1; try { if (a == 1) { throw e; } } catch (Exception e1) { System.out.print("catch in foo2. "); } /* 代码继续执行 */ System.out.println("foo2"); } /** * foo3 抛出异常 * @throws Exception */ public static void foo3() throws Exception { Exception e = new Exception(); int a = 1; if (a == 1) { throw e; } /* 代码中断 */ System.out.println("foo3"); } } 输出: //catch in foo2 //foo2 //something wrong!