You could implement hashCode
/equals
of your AuctionItem
so that two of them are equal if they have the same name. When you do this you can use the methods indexOf
and contains
of the ArrayList
like this: arrayList.indexOf(new AuctionItem("The name"))
. Or when you assume in the equals method that a String is passed: arrayList.indexOf("The name")
. But that's not the best design.
But I would also prefer using a HashMap
to map the name to the item.