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>();
I have the following code:
List<Product> product = new List<Product>();
The error:
Cannot instantiate the type List<Product>
本文解释了一个常见的Java编程错误:尝试直接实例化List接口而非使用其实现类(如ArrayList)。展示了正确的创建List实例的方法。

被折叠的 条评论
为什么被折叠?



