Android ArrayList: check an element exists of another ArrayList <p>I have two <code>ArrayList</code>.</p> <pre><code>private ArrayList&lt;Friend&gt; friendsList = new ArrayList&lt;Friend&gt;(); private ArrayList&lt;Friend&gt; myFriendsList = new ArrayList&lt;Friend&gt;(); </code></pre> <p>First one contains all <code>Friend</code> of database. Second one contains only user <code>Friend</code>. In my search option(<code>SearchManager</code>) i've a <code>ListView</code> contains searched friends of <code>friendsList</code>. When i select a <code>Friend</code> of <code>ListView</code>, i want to check if the <code>Friend</code> exists in <code>myFriendsList</code>. I used following code</p> <pre><code>friendListView .setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { handelListItemClick(adapter.getItem(position)); } }); private void handelListItemClick(Friend friend) { for(Friend fr: myFriendsList){ Log.v("Check User Name:", fr.getName()); } if (myFriendsList.contains(friend)) {works with matched friend} </code></pre> <p>But it can't check the selected <code>Friend</code> in <code>myFriendsList</code>. In <code>LogCat</code> it show <code>myFriendsList</code> information. Thanks in advance.</p> <p><strong>Update</strong> Here is my <code>Friend</code> class</p> <pre><code>public class Friend { private String id, name, thumbnailUrl; public Friend() { } public Friend(String name, String thumbnailUrl) { this.name = name; this.thumbnailUrl = thumbnailUrl; } public Friend(String name, String thumbnailUrl, String id) { this.name = name; this.thumbnailUrl = thumbnailUrl; this.id = id; } public String getID(){ return id; } public void setID(String id){ this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getThumbnailUrl() { return thumbnailUrl; } public void setThumbnailUrl(String thumbnailUrl) { this.thumbnailUrl = thumbnailUrl; } </code></pre> <p>}</p>