class ?FuShuException ? extends ? RuntimeException{ FuShuException (String ?msg) { super(msg); }}class ?Demo{ int ?div(int a, int ?b)throws ? Exception//throws ?ArithmeticException { if(b<0) throw ?new ? Exception("出現(xiàn)了除數(shù)為負(fù)數(shù)了"); if(b==0) throw ?new ? ArithmeticException("被零除啦"); return ?a/b; }} class ? ExceptionDemo4 { public ? static ?void ?main(String[] ?args) { Demo ?d=new ?Demo(); int ?x=d.div(4,-9);System.out.println("x="+x);System.out.println("over"); } } ??
添加回答
舉報
0/150
提交
取消