Using the arraylist is java
I have made an arrayList of type CartItem, basically it stores all the cartItems in one list.

now once a CartItem has already been added, instead of adding the same CartItem again, it will increase its quantity by one, rather than adding the element again in the list.

For this in my CartItem class, i have the following attributes

int Productid;
Product prod;
int QUANTITY;


now when i create a new arraylist

public ArrayList<CartItem> Items = new ArrayList<CartItem>();

CartItem newItem = new CartItem(productId)

Items.contains(newItem)  (this always returns false when if a item is bneing added twice, am i using the wrong logic ???)

Using the arraylist is java
===

I have made an arrayList of type CartItem, basically it stores all the cartItems in one list.

now once a CartItem has already been added, instead of adding the same CartItem again, it will increase its quantity by one, rather than adding the element again in the list.

For this in my CartItem class, i have the following attributes

int Productid;
Product prod;
int QUANTITY;


now when i create a new arraylist

public ArrayList<CartItem> Items = new ArrayList<CartItem>();

CartItem newItem = new CartItem(productId)

Items.contains(newItem)  (this always returns false when if a item is bneing added twice, am i using the wrong logic ???)
