i have a arraylist where i am verifying particular object is existing or not but even it exists it always returns false
<p>hi i have class called userdata which returns the Userarraylist which is of type User. when ever i try to use contains method to check particular property is existing or not it always returns false why? </p>

<p>Actually i want the array list to be generic which should return the objects that are set in array list.</p>

<pre><code>String className = data.getUserData().get(0).getClass().getSimpleName();

if(className.equalsIgnoreCase("User")) {
   ArrayList&lt;User&gt; userdata=new ArrayList(); 
   userdata = data.getUserData();
   System.out.println(data.getUserData().contains(u.getUserId())); 

   if(userdata.contains(u.getUserName())) {
      System.out.println(userdata.get(0).getEmailId()); 
   }
}
</code></pre>
