title: How to create multiple object of same data class kotlin
body: <p>I don't want to modify <code>oldList</code> I want to change only <code>newList</code> but whenever i change <code>newList</code>, <code>oldList</code> also modified.</p>
  <p>please help.</p>
  <pre><code>data class Cat(
      val id: String,
      var image: String
      var details: String
  )
  
  fun main() {
  
      val oldList= listOf(
          Cat(&quot;id1&quot;, &quot;img1&quot;, &quot;details1&quot;),
          Cat(&quot;id2&quot;, &quot;img2&quot;, &quot;details1&quot;),
          Cat(&quot;id3&quot;, &quot;img3&quot;, &quot;details1&quot;),
      )
      println(list)
  
      val newList = oldList
      newList.onEach {
          cat -&gt;
          cat.image = &quot;web_&quot; + cat.image
          cat.details= &quot;detail_xyz&quot; + cat.details
      }
  
      println(newList)
      println(list)
  
  }
  </code></pre>