回避异常的处理方式

package zuizhong;

public class Test5 {


    public static void main(String[] args) throws Exception  {
    try {
        int s=divide(100, 0);
    } catch (Exception e) {
    throw e;
    }
        
    }
    
public static    int divide(int a,int b) throws Exception{
            if(b==0){
                Exception e=new Exception("除数不能为零");
                throw e;
            }else return a/b;
        }
}

 

posted @ 2017-04-23 13:56  苏轼的红烧肉  阅读(132)  评论(0编辑  收藏  举报