现在的位置: 首页 > 综合 > 正文

Cannot instantiate the type List

2014年05月22日 ⁄ 综合 ⁄ 共 319字 ⁄ 字号 评论关闭

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>

抱歉!评论已关闭.