Property must be initialized or be abstract

前端 未结 2 377
情话喂你
情话喂你 2021-02-01 11:17

It must be stupid question, but I\'m really new to Kotlin and I didn\'t find any solution.

How to declare class field? Like we can have it in java:

prote         


        
2条回答
  •  梦谈多话
    2021-02-01 12:13

    Pulling this out of the comments from Alexander Udalov's answer for visibility. For nullable properties:

    protected var sharedPreferences : SharedPreferences? = null

    ...and assign it a value later.

提交回复
热议问题