There is a basket, there is an implementation of its viewing, there are all possible products, etc. Basket - ArrayList. Items are added to the basket when I want to add them, and hence the question - how to remove them from there?
public static void cart () { Scanner sc = new Scanner(System.in); for (int i = 0; i < cart.size(); i++) { System.out.println(cart.get(i)); } System.out.println("Enter 9 to remove products out of your cart."); int s = sc.nextInt(); do { cart.remove(s); } while (s<=11); } In this code, I tried to remove the goods in cart.remove (s) as many times as the user writes (s-number of times). But something is wrong. I tried and through for, also did not work. Help please who can, I will be very grateful. Please insert the code with the answer. Thank you in advance.