how can i remove an element that i had added before in the ArrayList<> I create it like that:
public static ArrayList<Product> P = new ArraList<Product>(); 
the method I am using:
public void removeProduct(Product p) {
    P.remove(p); // this way, did not solve the problem 
} 
// I did the (added the method) and it works and everything are fine, I hope someone could help to get the answer and thanks :)
public void deleteProduct(String ID) {
    System.out.println("Enter product id to delete: ");
    ID = input.next();
    for(Product m : s.P) {
        if(ID.equals(m.getID())) {
            s.P.remove(ID);
        }
        else {
            System.out.println("ID is not exist");
        }
    }
}
// and
public void removeProductToCart(Product p) {
    viewShoppingCart();
    System.out.println("Enter product id to remove it: ");
    String ID = input.next();
    for(Product r : s.P) {
        if(ID.equals(r.getID())) {
            s.P.remove(p);
        }
        else {
            System.out.println("ID is not exist");
        }
    }
}
 
     
     
    