异常

关键字:try catch throw throws final

try和catch要必须初选,final可以不出现

快捷键:ctrl+alt+t

package oop;
import static java.lang.Math.random;
public class Application {
    public static void main(String[] args) {
        try {
            new Application().run();
        } catch (Exception e) {
            System.out.println("程序出现异常啦");
            throw new RuntimeException(e);
        }finally {
            System.out.println("finally");
        }
    }


    public void run(){
        System.out.println(1/0);
    }
}

posted on 2022-07-21 14:54  clinch  阅读(122)  评论(0编辑  收藏  举报