I hope to initial the private a var id later, so I use the code private lateinit var id:Int
But I get the error 'lateinit' modifier is not allowed on properties of primitive type, why? How can I fix it? Thanks!
Code A
class UIAddEditBackup: AppCompatActivity() {
private lateinit var mContext: Context //OK
private var isAdd: Boolean=false //OK
private lateinit var id:Int // I get the error
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.layout_add_edit_backup)
id=5
}
}