首页 > 技术文章 > java 异常机制

d534 2021-08-03 21:01 原文

异常

异常分类

异常的体系结构

Error 错误

Exception 异常

package exception;

public class Demo01 {
    public static void main(String[] args) {
//        new Demo01().a(); //Exception in thread "main" java.lang.StackOverflowError

        System.out.println(11/0);//Exception in thread "main" java.lang.ArithmeticException: / by zero
    }

    public void a() {
        b();
    }

    public void b() {
        a();
    }
}

推荐阅读