重载和重写的区别(The difference between overloading and rewriting)

重载: 同一个类中多个同名方法根据不同的传参来执行所对应的方法

重写: 子类根据需要,对父类的允许访问的方法的实现过程进行重新编写, 返回值和形参都不能改变

————————

< strong > overloading: < / strong > multiple methods with the same name in the same class execute the corresponding methods according to different parameters

< strong > rewrite: < / strong > subclasses rewrite the implementation process of the allowed methods of the parent class as needed, and the return value and formal parameters cannot be changed