zoukankan      html  css  js  c++  java
  • java-重写

    重写有要求

    1. 方法名:必须和父类被重写的方法名相同
    2. 形参列表:必须和父类被重写的方法名相同
    3. 返回值类型:
        A. 基本数据类型和void:要求与父类被重写的返回值数据类型一致
        B. 引用数据类型:要求子类重写的方法返回值类型 <= 父类被重写的方法的返回值类型
            ## 例如:子类方法的返回值类型是Student,父类被重写的方法的返回值类型Student
                    子类方法的返回值类型是Student,父类被重写的方法的返回值类型是Person
                    子类方法的返回值类型是Person,父类被重写的方法的返回值类型是Student(这个是错误的)
    4. 修饰符
        A. 权限修饰符:子类重写方法的权限修饰符的可见范围 >= 父类被重写的权限修饰符的可见范围
        B. 其他修饰符:
    
    When nothing seems to help, I go look at a stonecutter hammering away at his rock, perhaps a hundred times without as much as a crack showing in it. Yet at the hundred and first blow it will split in two, and I know it was not that blow that did it, but all that had gone before. -- Jacob Riis
  • 相关阅读:
    抽象类和接口
    回调函数
    Spring Aop、拦截器、过滤器的区别
    事务
    SQL 模糊查询条件的四种匹配模式
    shell编程(二)
    shell编程(一)
    shell介绍
    字符验证码
    selenium
  • 原文地址:https://www.cnblogs.com/xhwy-1234/p/12377942.html
Copyright © 2011-2022 走看看