It seems in an Activity, for example, the onCreate() method, it does not make much difference if I have the @Override annotation or not. They both work. (As long as I call super.onCreate() inside the callback , it will call the parent class' method.)
Can someone tell me why we need to have the @Override annotation for life-cycle callbacks in Activity ?
I ask this because I tested without @Override annotation, my app still running successfully.
This is more like a good development practice.
If by mistake you want to override a method that doesn't exist in the super class (or interfaces implemented) you'll get an error.
Think that you want to override "onCreate" but you misspell it and write "onCreatee". With that annotation, you'll get an error. Without it, you'd end up spend a lot time trying to understand why your initialization method was not working properly.
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