在Java和其他一些高级面向对象的编程语言中,子类可继承父类中的方法,而不需要重新编写相同的方法。但有时子类并不想原封不动地继承父类的方法,而是想作一定的修改,这就需要采用方法的重写。方法重写又称方法覆盖。
我们实际上可以用多种方法重写上一个例子的最后一行。
We could actually write the last line of the previous example in several ways.
另一方面,可以照下面的方法重写单参数构造器来修复错误。
On the other hand, the bug could be fixed by rewriting the single-argument constructor as follows.
该参数可以被过程或者是方法引用。但该参数的值不可以被过程或者是方法重写。
IN - the parameter can be referenced by the procedure or function. The value of the parameter can not be overwritten by the procedure or function.
应用推荐