阅读背景:

java编译异常,运行异常的区别(二)_JobShow裁员加班实况-微信小程序_java编译异常

来源:互联网 
public class Test15 {

/*    public static void main(String[] args) {//运行时异常不用主动捕获或者抛出
        Test15 test15 = new Test15();
        test15.doSomething();
    }

    public void doSomething() throws ArithmeticException {
        System.out.println("123");
    }
    //main方法中不捕获也不抛出ArithmeticException,也能正常运行,输出:123*/


    public static void main(String[] args) throws FileNotFoundException {//检查异常必须要主动捕获或者抛出,在反射时需要主动捕获的异常也属于检查异常
        Test15 test15 = new Test15();
        test15.doSomething();
    }
    //main方法中必须要捕获或者抛出FileNotFoundException,才能正常运行,输出:123,如果不在main中抛出或捕获FileNotFoundException,则doSomething()下面有红线提示

    public void doSomething() throws FileNotFoundException {
        System.out.println("123");
    }
}public class Test15 {

/*    public static void



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: