title: How can I access a variable from different file in kotlin?
body: <p>I am trying to add items to a list and I want to display a list of all the items. I have made a list in <code>MainActivity.kt</code> but how can I access this list in another <code>kotlin</code> file? </p>
  
  <p>Here I make the list and I add items.</p>
  
  <pre><code>class MainActivity : AppCompatActivity() {
  
      public val itemList= arrayListOf("one", "two", "three", "four")
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          addItemBtn.setOnClickListener {
              val new = addItemTxt.text.toString()
              if (!itemList.contains(new)){
                  itemList.add(new)
              }
              addItemTxt.text.clear()
          }
  
  
          listButton.setOnClickListener {
              startActivity(Intent(this, ListChoose::class.java))
          }
  
      }
  
  }
  </code></pre>