2017-06-29
package Java.Test;
public class Throw11 {
public static void test3(boolean isThrow)throws Exception{
System.out.println("进入test3()。。。");
try{
if(isThrow){
throw new Exception();
}
}
catch(Exception e){
System.out.println("出异常了 我继续抛");
//throw e;
}
System.out.println("正常运行了");
}
public static void main(String[] args) {
try{
//test3(false);
int c = 10/0;
int c1=10/2;
}
catch(Exception e){
System.out.println("出错了");
e.printStackTrace();
}
}
}
识别异常并且了解异常的分类,数学异常,空指针异常,数组越界异常等,他们的父类是异常,主方法里抛出异常和用try发现异常 catch捕获异常他们都可以消除代码中出现的异常但是他们的作用不一样,我们可以分情况使用
浙公网安备 33010602011771号