throws子句在继承当中overrride时有什么规则?

8.throws子句在继承当中overrride时的规则  (视频下载) (全部书籍) 马克-to-win:当子类方法override父类方法时,throws子句不能引进新的checked异常。换句话说:子类override方法的throws子句checked异常不能比父类多。马克-to-win:上面一条是死语法规定,这种规定,实际上都是源于checked异常这种最初的设计。

例:1.8.1-本章源码

import java.io.IOException;
class Animal{
    void call() throws IOException
    {
        System.out.println("Animal");
    }
}
class Dog extends Animal{
    void call() throws IOException
    {
        System.out.println("Dog");
    }
}

public class Test {
    public static void main(String args[]) throws IOException {

。。。。。。。。。。。。。。。。。
详情请进:http://www.mark-to-win.com/index.html?content=JavaBeginner/javaUrl.html&chapter=JavaBeginner/JavaBeginner5_web.html#throwsInInheritanceOverride

猜你喜欢

转载自www.cnblogs.com/mark-to-win/p/9695367.html