try catch finally

来源:互联网 发布:手机淘宝网店怎么铺货 编辑:程序博客网 时间:2024/05/16 14:01




package trycatch;/** * 工作嘛,谈不上喜欢不喜欢,就是遇到问题拷贝黏贴下。 * 多了解点总是好的,多自己去动手。 * * @author ZengWenFeng */public class TryCatchFinallyDemo{public static int test(){int i = 1;try{System.out.println("try : " + i);return i / 0;}catch (Exception e){i++;System.out.println("catch : " + i);e.printStackTrace();}finally{i++;System.out.println("finally : " + i);//return i;//测试用的}System.out.println("return : " + i);return i;}public static void main(String[] args){System.out.println(test());}}


原创粉丝点击