java 错误抛出顺序

来源:互联网 发布:网络合作合同 编辑:程序博客网 时间:2024/04/28 22:26
/** * Created with IntelliJ IDEA. * User: 周海明 * Date: 2016/12/30 * Time: 14:14 */public class Body {    public static void main(String[] args) {        new Body().a();    }    public void a() {        try {            b();        } catch (Exception e) {            System.out.println("a这里错误了");            e.printStackTrace();        } finally {            System.out.println("a错误了");        }    }    public void b() {        try {            int i = 1;            int j = 0;            int f;            f = i / j;        } catch (Exception e) {            System.out.println("b这里错误了");            e.printStackTrace();        } finally {            System.out.println("b错误了");        }    }

}

输出:

b这里错误了java.lang.ArithmeticException: / by zeroat Body.b(Body.java:33)at Body.a(Body.java:18)at Body.main(Body.java:13)b错误了a错误了

0 0
原创粉丝点击