title: Check if an apex list contains an object
body: <p>Is there any way to check if a list contains a certain element?  I looked at the List functions and did not see any contain() function like Java or C# , so I was wondering how other people are handling this.</p>
  
  <p>I really need to use a List I <strong>cant</strong> use a <strong>Map</strong> like in this example <a href="http://boards.developerforce.com/t5/Apex-Code-Development/Check-if-a-list-contains-an-object/td-p/98131" rel="noreferrer">here</a> </p>
  
  <p>What I have now is really bad..</p>
  
  <pre><code>                    for  (String s : allContacts)
                      {                      
  
                        for(String ic:insertedContacts)
                          {                          
                              if (s != ic )
                              {
                                       errorContacts.add(s);
                                       break;
                              }
                              break;
                          }
                   }
  </code></pre>