Linear search over an ArrayList using a String as a parameter
<p>I am trying to search for a String contained in an ArrayList in my method, findContactsByName, using a for-each loop, if the String is found in the Contact then the Contact is returned and if the String is not found then null is returned. However when testing my code null is returned all the time, here is my code:</p>

<pre><code>import java.util.*;

public class Phonebook {
    private String owner;
    private ArrayList&lt;Contact&gt; contacts = new ArrayList&lt;Contact&gt;();

    public void addContact(Contact contact) {
        contacts.add(contact);
    }

    public void show() {
        System.out.println(owner + "'s phonebook");
        for (Contact contact : contacts) {
            System.out.println(contact);
        }
    }

    public Contact findContactByName(String name) {
        for (Contact contact : contacts) {
            if (contacts.contains(name)) {
               return contact;
           }
       }
       return null;
    }
}
</code></pre>