package itheima_05;
public class Demo02 {
public static void main(String[] args) {
int a=1;
int b=0;
test(a,b);
}
public static void test(int a,int b){ //try catch的作用:捕获异常,打印异常,出现异常对异常进行处理,继续向下面执行
try {
System.out.println(a/b);
} catch (Exception e) {
e.printStackTrace();
System.out.println("这是异常");
} finally {
}
System.out.println("1");
}
// public static void main(String[] args) throws Exception{ //throws关键字的作用:抛出异常,在哪抛出,程序就在哪结束
// int a=1;
// int b=0;
// test(a,b);
// }
// public static void test(int a,int b){
// System.out.println(a/b);
// }
}