i have a arraylist where i am verifying particular object is existing or not but even it exists it always returns false

Posted by Raghavender Reddy on Stack Overflow See other posts from Stack Overflow or by Raghavender Reddy
Published on 2012-10-17T04:39:42Z Indexed on 2012/10/17 5:01 UTC
Read the original article Hit count: 135

Filed under:

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?

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

String className = data.getUserData().get(0).getClass().getSimpleName();

if(className.equalsIgnoreCase("User")) {
   ArrayList<User> 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()); 
   }
}

© Stack Overflow or respective owner

Related posts about java