Cannot instantiate the type List<Product> [duplicate] Cannot instantiate the type List<Product> [duplicate] java java

Cannot instantiate the type List<Product> [duplicate]


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>();


Use a concrete list type, e.g. ArrayList instead of just List.


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.