title: Comparing two lists in kotlin
body: <p>I came across with kotlin <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-abstract-list/equals.html" rel="noreferrer">equals</a> function to compare two list of same type. It works fine for pure Kotlin with data classes.</p>
  
  <p>I'am using a Java library in Kotlin project in which a callback method returns a list of objects for a time interval of X seconds. Trying to compare the old list with new list for every call, but equals returns false even the items are same and equal.</p>
  
  <pre><code>val mOldList: MutableList&lt;MyObject&gt;()? = null
  
  override fun updatedList(list: MutableList&lt;MyObject&gt;){
      // other code
      if (mOldList.equals(list)) // false everytime
  }
  </code></pre>
  
  <p>Is this because of Java's equals method from library?</p>
  
  <p>Alternative suggestions for list compare would be appreciative. </p>