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