title: How ArrayList contains method work?
body: <p>I've a doubt about how ArrayList contains method works. Let's take an example:</p>
  
  <pre><code>List&lt;String&gt; lstStr = new ArrayList&lt;String&gt;();
  String tempStr1 = new String("1");
  String tempStr2 = new String("1");
  
  lstStr.add(tempStr1);
  
  if (lst.contains(tempStr2))
      System.out.println("contains");
  else
      System.out.println("not contains");
  </code></pre>
  
  <p>it returns 'not contains'.</p>
  
  <p>Another example:</p>
  
  <pre><code>List&lt;LinkProfileGeo&gt; lst = new ArrayList&lt;LinkProfileGeo&gt;();
  LinkProfileGeo temp1 = new LinkProfileGeo();
  temp1.setGeoCode("1");
  LinkProfileGeo temp2 = new LinkProfileGeo();
  temp2.setGeoCode("1");
  
  lst.add(temp1);
  
  if (lst.contains(temp2))
      System.out.println("contains");
  else
     System.out.println("not contains");
  </code></pre>
  
  <p>It returns contains. So how does contains method works ?</p>
  
  <p>Thanks</p>