I have a list of a custom class object I created.
private List<Grocery> groceryList;
where Grocery class has name, price , quantity variables and getters...
And I want to check if a grocery product already exist in my list or not,if doesn't exist I want to add it to my list, here is my code:
CheckOut hisCheckOut = new CheckOut(itemName ,String.valueOf(price), String.valueOf(orderQuantity), String.valueOf(itemTotalPrice));
    if(!(GroceryActivity.list.contains(itemName))){
        GroceryActivity.list.add(hisCheckOut);
        GroceryActivity.totalItemsPrice += itemTotalPrice;
    }
itemName is a variable with a normal string name .This is not working.
 
     
     
    