首页 > 代码库 > 回避异常的处理方式

回避异常的处理方式

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

 

回避异常的处理方式