Main.java uses unchecked or unsafe operations ArrayList<Product> cartItems = myCart.getItemsList();

81 Views Asked by At

I am getting the warning Note: Main.java uses unchecked or unsafe operations. in the following code

ArrayList<Product> cartItems = myCart.getItemsList();

How to remove this warning.

1

There are 1 best solutions below

1
Chakrit W On BEST ANSWER
  1. Does your myCart.getItemsList() returns List or ArrayList, and does the type have parameter <Product>?
  2. You might consider using List<Product> cartItems, which should be sufficient in most cases, and make sure myCart.getItemsList() returns List<Product>.