zoukankan      html  css  js  c++  java
  • Overload and Override without Overwrite

    Override(覆盖/覆写): 子类Override父类中的函数(方法)。
    Overload(重载): 同一个类中包含多个同名的函数(方法), 但各个函数的参数列表不同。

    Override和Overload是Java多态性的不同表现:
    Override是父类与子类之间多态性的表现; Overload是同一个类中多态性的表现。
    Override是运行时多态;Overload是编译时多态。

    Overwrite:Java中就没有它的存在, Java官方文档没有该词的出现, 但是国外有人把Overwrite解释为Override。
    "Overriding, which is what I think you mean by 'overwriting' is the act of providing a different implementation of a method inherited
    from a base type, and is basically the point of polymorphism by inheritance."

    A good explanation on StackOverflow is as follow:
    "If you're replacing one implementaion completely with another, it's 'overwriting' or more commonly 'replacing'. If you're replacing
    an implementation with another for some specific cases, it's 'overriding'.
    To 'overwrite' something is to put something else in its place, destroying the thing overwritten. To 'override' something is to cause
    something else to operate instead of it without harming or changing the thing overridden."

    参考:
    java override overwrite与overload: http://bijian1013.iteye.com/blog/1924157

  • 相关阅读:
    Day5下午解题报告1
    Linux 命令整理
    [置顶] 正则表达式应用:匹配email地址
    IE浏览器下web调试工具之--IE WebDeveloper介绍
    ORACLE客户端乱码
    冒泡排序
    【C++】第二章:Hello World!
    hdu4710
    (SQL SERVER) (ORACLE) (ACCESS)(POSTGRE SQL)四种数据库操作C#代码
    How to calculate the undo_retention time
  • 原文地址:https://www.cnblogs.com/lxw0109/p/java_polymorphism.html
Copyright © 2011-2022 走看看