问题描述
我有以下代码:
List<Product> product = new List<Product>();
错误:
Cannot instantiate the type List<Product>
Product 是我的 E** 项目中的一个实体.为什么会出现此错误?
Product is an Entity in my E** project. Why I'm getting this error?
推荐答案
List 是一个接口.接口不能被实例化.只能实例化具体类型.您可能想使用 ArrayList,是List接口的实现.
List<Product> products = new ArrayList<Product>();