I want to be able to have LinkedList.contains() return true for a custom comparator.
Suppose that I have 1 LinkedList and 2 objects
LinkedList
You need to override the .equals(Oject) and the .hashCode() methods in the MyObject class (hashCode isn't needed for the List... but when you overrite equals the contract says you have to override hashCode).
Essentially what the contains does is this:
for(each item in the list)
{
if(theCurrentItem.equals(theItemYouAreLookingFor))
{
return (true);
}
}
return (false);
Take a look at the documentation for Object (for equals and hashCode) here
Also a really good book to read is Effective Java