1、代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | class Demo{ public static void main(String args[]){ System.out.println("1"); try{ System.out.println("2"); int i = 1/0; System.out.println("3"); }catch(Exception e){ e.printStackTrace(); System.out.println("4"); }finally{ System.out.println("finally"); } System.out.println("5"); } } |
运行结果
1 2 3 4 5 6 7 | 1 2 java.lang.ArithmeticException: / by zero at Demo.main(Demo.java:6) 4 finally 5 |