Hi,
I have an ArrayList of objects type Contact. Every Contact contains first name, last name, phone number and e-mail (all of them String).
I have to write a method which search for a keyword in the records and return true if this keyword has been found anywhere in it. The method I came up with is:
public boolean match(Object otherObject)
{
if (otherObject ==null)
{
return false;
}
else if (getClass() != otherObject.getClass())
{
return false;
}
else
{
Contact otherContact = (Contact)otherObject;
return (first.equals(otherContact.first) ||
last.equals(otherContact.last)||
phone.equals(otherContact.phone)||
email.equals(otherContact.email));
}
}

and it works fine. The problem is that in this case it returns true only if the two values are exactly the same. I need to modify it in a way that even if the keyword is "ohn" records with name "John" to return true. It has to work with any keyword and to search for it in all object variables. Thanks