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; } }
时间: 2024-12-23 09:17:57