finally 语句

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);
    }
}

 

posted @ 2016-07-31 08:58  超级学渣渣  阅读(167)  评论(0编辑  收藏  举报