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

异常的抛出

时间:2014-08-05 10:42:19      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:style   color   io   ar   div   new   c   return   

 

div的异常抛给main来处理:

class Math{
    public int div(int i,int j)throws Exception{
        int temp=i/j;
        return temp;
    }
}
public class ThrowsDemo01 {
public static void main(String[] args){
    Math m=new Math();
        try {
            System.out.println("Divation opration: "+m.div(10, 0));
        } catch (Exception e) {
            e.printStackTrace();
        }
}
}

异常的抛出,布布扣,bubuko.com

异常的抛出

标签:style   color   io   ar   div   new   c   return   

原文地址:http://www.cnblogs.com/vonk/p/3891559.html

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