Possible Duplicate:
When do you use Java's @Override annotation and why?
Newbie question - I'm writing my first Android app (its my 2nd Java app). I noticed that in examples the onCreate()
method has the @Override
annotation, but I haven't used that annotation and it seems to work fine.
Is it just good practice to use the @Override
annotation or am I setting myself up for problems. What about the other inherited methods - onPause
etc?
The @Override
annotation allows the compiler to ensure you're actually overriding a method or implementing an interface method (Java 6+). This can avoid one class of simple errors, like screwing up a method signature and not actually overriding what you think you are.
It's not mandatory, but it's a good idea, and is free help from the compiler.
It's only good practice, which
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With