The label ---- @ Override

Original link: https://www.cnblogs.com/larry2016/p/7640741.html

@Override is the pseudo code indicating rewrite (of course you can not write too), but has the following advantages that read:
1, you can be annotated with easy to read;
2, the compiler can give you the name of an authentication method @Override whether the following your parent in all, if not the error. For example, if you did not write @Override, and your name and the following method was wrong, then your compiler can compile because the compiler that this method is your own subclass added methods.
 
Example: when rewriting onCreate parent class, method of adding in front @Override system can help you check the accuracy of the method.
@Override
public void the onCreate (Bundle savedInstanceState)

{......}
such an approach is correct, if you write:

@Override
public void oncreate (Bundle savedInstanceState)
{.} ......
The compiler will report the following error: The method oncreate (Bundle) of type HelloWorld must override or implement a supertype method, to make sure you properly override the onCreate method (because oncreate should as onCreate). And if you do not add @Override, the compiler will not detect an error, but will consider a new method you define a subclass: oncreate

Guess you like

Origin www.cnblogs.com/ncwoniu/p/11526058.html
Recommended