- class FuException extends Exception
- {
-
- FuException(String ms)
- {
- super(ms);
- System.out.println("111111111================");
-
- }
- }
- class Demo
- {
- int div(int a,int b) throws FuException
- {
-
- System.out.println("-------------");
- if(b <0)
- {
- System.out.println("++++++++++++++");
- throw new FuException("不能为负数-------55555");
- }
- return a/b;
- }
- }
- class ExceptionDemo
- {
- public static void main(String[] args)
- {
- Demo d = new Demo();
- try{
-
- int num = d.div(3,-1);
- System.out.println("num = "+num);
- }
- catch(FuException e)
- {
- System.out.println("222222============");
- System.out.println("不能为负数");
- }
-
- System.out.println("over");
-
- }
- }
复制代码 运行结果是:-------------
++++++++++++++
111111111========
222222============
不能为负数
over
我想要的结果是:-------------
++++++++++++++
111111111========
不能为负数-------55555
over
怎么才能执行到这样的结果呢? |