How to force derived class to call super method? (Like Android does)

前端 未结 8 2291
余生分开走
余生分开走 2020-12-08 04:00

I was wondering, when creating new Activity classes and then overriding the onCreate() method, in eclipse I always get auto added: super.onCr

8条回答
  •  误落风尘
    2020-12-08 04:20

    Eclipse just helps you doing things right and avoid exceptions.

    From http://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)

    Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

提交回复
热议问题