should I call super.xxxx() before my custom code or after when I override a method?
Is there some skills to Identify?
should I call super.xxxx() before my custom code or after when I override a
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The short answer: It Depends.
The long answer:
You need to understand what the implementation of the method in the parent class does.
super.myMethod()call should be the first line in the method.superthe last line in your overridden implementation.Activitylife cycle methods fall in this category. Which is why you must call though tosuper.onCreate()although you can do it at any point in youronCreate().null, you might create a new object and return that instead.supermethod must be called.