标签:
1 public class ThrowsTest 2 { 3 public static void main(String[] args) 4 { 5 try 6 { 7 mothed(); 8 } 9 catch (Exception ex) 10 { 11 ex.printStackTrace(); 12 } 13 } 14 15 private static void mothed() throws Exception 16 { 17 try 18 { 19 System.out.println("异常前........."); 20 int num = 1 / 0; 21 System.out.println("异常后........."); 22 } 23 finally 24 { 25 System.out.println("异常后的finally中..............."); 26 } 27 } 28 }
run:
异常前.........
java.lang.ArithmeticException: / by zero
异常后的finally中...............
at com.gzy.throwsTest.ThrowsTest.mothed(ThrowsTest.java:34)
at com.gzy.throwsTest.ThrowsTest.main(ThrowsTest.java:21)
成功构建 (总时间: 0 秒)
标签:
原文地址:http://www.cnblogs.com/starman/p/5012788.html