I am trying to compare weather an item is contained within the arrayList and if it is then remove it. Im not sure weather I have to implement my own equals method or not, this is my code but it isn't working to remove the correct item.
public boolean removeItem(Item item) {
for(int i = 0; i < items.size(); i++) {
if (items.get(i).equals(item)) {
items.remove(item);
return true;
}
}
return false;
}
containsandremovemethods ofArrayList.Itemclasscontainsnot equals`. You don't even need to loop it.