脚本宝典收集整理的这篇文章主要介绍了异常补充,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
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);// }}
以上是脚本宝典为你收集整理的异常补充全部内容,希望文章能够帮你解决异常补充所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。