title: Dynamic array of views in Kotlin
body: <p>I am trying to create dynamic <code>TextView</code> by creating an array of <code>TextViews</code> but getting error :</p>
  
  <pre><code>java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
  </code></pre>
  
  <blockquote>
    <p>My Code:</p>
  </blockquote>
  
  <pre><code>var txtViews = arrayOfNulls&lt;TextView&gt;(3)
      for (i in txtViews.indices) {
          txtViews = arrayOfNulls(i)
          txtViews[i]?.textSize = 24.0F
          txtViews[i]?.text = "Hello"
          txtViews[i]?.setTextColor(ContextCompat.getColor(this,
          R.color.colorAccent))
          layout.addView(txtViews[i])
      }
  </code></pre>