title: Java ArrayList IndexOf - Finding Object Index
body: <p>Lets say I have a class</p>
  
  <pre><code>public class Data{
      public int k;
      public int l;
      public Data(int k, int l){
        this.k = k; 
        this.l = l;
      }
      public boolean equals(Date m){
        if(this.k == m.k &amp;&amp; this.l = m.l)
             return true;
        return false;
      }
  }
  </code></pre>
  
  <p>And I add a few Data objects to a ArrayList:</p>
  
  <pre><code>ArrayList&lt;Data&gt; holder = new ArrayList&lt;Data&gt;;
  Data one = new Data(0,0);
  Data two = new Data(0,4);
  Data three = new Data(0,5);
  </code></pre>
  
  <p>Why does indexOf not find this?:</p>
  
  <pre><code>holder.indexOf(new Data(0,4)); //returns -1
  </code></pre>
  
  <p>Is indexOf any better than going through the whole array list myself? Or am I missing something.</p>