这句话的翻译肯定有些问题。我的理解是这样的比如父类里有函数f() throws ex1那子类里不能再f() throws ex1,就是说异常不能这样传递抛出,不知道楼主认为如何?

解决方案 »

  1.   

    楼上说的这样可以呀?
    如下:class ThrowException1
    {public int x;
     public void throw1() throws ArithmeticException
     {x=0;
     x=3/x;
     x=1;
                    System.out.println("x="+x);
            }
    }
    public class ThrowException extends ThrowException1
    {       public void throw1() throws ArithmeticException
            {x=0;
            x=3/x;
            x=1;
            System.out.println("x="+x);
            }
            public static void main(String[] args)
            {       ThrowException t = new ThrowException();
                    try{
                            t.throw1();                        }
                            catch (Exception e){System.out.println("begin!!!!!!")
     e.printStackTrace();
                            System.out.println("get message="+e.getMessage());
                            }
                            }
                            }
    编译运行都正常呀?
      

  2.   

    sorry是我的理解有问题了。是这样的,如果父类函数不抛出异常,子类也不能抛出。如果父类函数抛出异常,那子类只能抛出同样的异常,就是说只有我写的那种情况才是没错误的。ft理解有问题,sorry