First, preface
There are now two classes of son and parent, and type son will override the GetName function of type parent. Unfortunately, due to the code of the agricultural idea, write the following code:
Public class parent{ public String getName () { return'Parent " ; }} Public class Son extends parent{ public String getnames () { return' Son"; }}
The above code compiles through and does not realize the realization error, tragedy happened ....
This is no longer the case with @Override annotations !
Second, @Override annotations
function : When a subclass function is added @Override , the function overrides the same signature function in the parent class, or the compilation fails.
Note: @Override only provides an accessibility hint function for overriding the parent class function, not a requirement for rewriting. Even without the annotation, the subclass function overrides the corresponding function of the parent class as long as the signature of the subclass function is the same as the parent class.
Respect the original, reprint please specify: http://www.cnblogs.com/fsjohnhuang/p/4040816.html ^_^ Fat Boy John
Third, reference
Http://www.cnblogs.com/liubiqu/archive/2008/06/01/1211503.html
Java Magic Hall: An explanation of annotation usage--@Override