I am matching two java Strings ,It matches most of the equal Strings but for some values it does not match even the Strings are totally same .
public static Person SearchPersonByID(String id)
{
for(int i=0;i<personList.size();i++)
{
Person p=new Person();
p=personList.get(i);
String useride=p.UserId.toString();
System.out.println(p.UserId+"=="+id);
if(useride.contains(id)||useride.equals(id))
{
System.out.println("Matched");
return p;
}
}return null;
}
I have debugged the program ,although values are exactly same still it is returning null. Here is the values i want to match ..Kindly help me
ahsan7==ahsan7
they are same and yet it returns null
public class Person {
String Status;
String MobileNo;
String Hobbies;
String PersonName;
String Password;
String LastSeen;
String UserId;
String location;
String Adress;
String EmailId;
String Type;
String ImageAdress;
int port;
DefaultListModel<String> FriendsList=new DefaultListModel<>();
Person()
{
}
}