码迷,mamicode.com
首页 > 其他好文 > 详细

finally 语句

时间:2016-07-31 09:07:24      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

package unit5;

public class FinallyDemo {

    int no1,no2;
    public FinallyDemo(String[] args) {

        try{
            no1=Integer.parseInt(args[0]);
            no2=Integer.parseInt(args[1]);
            System.out.println("相除结果结果为:"+no1/no2);
        }catch(ArithmeticException e1){
            System.out.println("除数不能为0");
        }catch (NumberFormatException e2) {

            System.out.println("必须输入数字");
        }finally{
            System.out.println("Finally 已执行,用于做清理");
        }
    }
    public static void main(String[] args) {
        new FinallyDemo(args);
    }
}

 

finally 语句

标签:

原文地址:http://www.cnblogs.com/superxuezhazha/p/5722344.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!