So, I'm trying to remove an object from an ArrayList. When I do it and print the ArrayList again, the object is still there.
else if (cmd==4){
System.out.println("Enter the product name: ");
String nameToRemove = input.next();
for (Product x : inventoryList){
if (nameToRemove == x.getName()){
inventoryList.remove(x);
}
}
}
Why won't the remove() method do anything when I implement it?