Difference between code before and after super()

后端 未结 3 1573
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-04 16:37

Look at the sample codes below

@Override
protected void onPause() {
    ...some code here...
    super.onPause();
}

and

@O         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 17:01

    Had to chip in with this link to a thread with an identical subject:

    super.onResume() at beginning or end of method? Does it matter?

    Note the quote from Dianne Hackborn

    Yeah this is a good pattern. In most cases it probably doesn't matter, but it's a general rule: during any kind of initialization, let the super class do their work first; during any kind of finalization, you do your work first.

提交回复
热议问题