How do you define private instance variables in Kotlin?

Viewed 44

So im trying to define a private class in kotlin/android studio. Am not sure what is going on, but i tried searching up videos on how to create a private class on kotlin. I stil don't think I know what to do. Any help?

package com.example.calculator

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.EditText

class MainActivity : AppCompatActivity() {

    private EditText display            <line of code that is highlighted in red.

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


    }

    public fun zeroBTN(args: View) {

    }

}
[enter image description here][1]```


  [1]: https://i.stack.imgur.com/kY6q7.png
1 Answers

That's not how to define variables in Kotlin. You probably want something like this:

private lateinit var display: EditText
Related