title: Can I use State<ArrayList<T>> or State<mutableListOf()> for observed by Compose to trigger recomposition when they change?
body: <p>The following content is from the <a href="https://developer.android.com/jetpack/compose/state" rel="nofollow noreferrer">article</a>.</p>
  <p>1: I don't understand fully if I can use <code>State&lt;ArrayList&lt;T&gt;&gt;</code> or <code>State&lt;mutableListOf()&gt;</code> for observed by Compose to trigger recomposition when they change?</p>
  <p>2: I'm very strange why <code>State&lt;List&lt;T&gt;&gt;</code> and the immutable <code>listOf()</code> can be observed by Compose to trigger recomposition when they change but in fact <code>List&lt;T&gt;</code> and immutable <code>listOf()</code> are immutable, could you give me some sample codes?</p>
  <blockquote>
  <p>Caution: Using mutable objects such as ArrayList or mutableListOf() as state in Compose will cause your users to see incorrect or stale data in your app.</p>
  <p>Mutable objects that are not observable, such as ArrayList or a mutable data class, cannot be observed by Compose to trigger recomposition when they change.</p>
  <p>Instead of using
  non-observable mutable objects, we recommend you use an observable
  data holder such as State&lt;List&gt; and the immutable listOf().</p>
  </blockquote>
  <p><strong>Image</strong>
  <a href="https://i.stack.imgur.com/HZOdY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HZOdY.png" alt="enter image description here" /></a></p>