Cannot instantiate the type List<Product> [duplicate]
Solution 1:
List
is an interface. Interfaces cannot be instantiated. Only concrete types can be instantiated. You probably want to use an ArrayList
, which is an implementation of the List
interface.
List<Product> products = new ArrayList<Product>();
Solution 2:
Use a concrete list type, e.g. ArrayList
instead of just List
.
Solution 3:
List is an interface. You need a specific class in the end so either try
List l = new ArrayList();
or
List l = new LinkedList();
Whichever suit your needs.