我尝试使用以下代码:
List<ItemInterface> interfaceList = new List<ItemInterface>();Eclipse出现错误:无法实例化类型列表
这段代码有什么问题?
发布于 2011-10-06 01:10:34
List本身就是一个接口。你需要使用类似这样的东西:
List<ItemInterface> interfaceList = new ArrayList<ItemInterface>(); 发布于 2011-10-06 01:09:49
List<T>是一个接口,不是一个类。
你可能指的是new ArrayList<T>()。
发布于 2011-10-06 01:11:46
List<T>是Java中的一个接口,你必须使用implement List的一个类。
下面是来自Java教程的一课/教程:http://download.oracle.com/javase/tutorial/collections/interfaces/
下面是List java文档,以及Java API中实现它的类的列表:http://download.oracle.com/javase/6/docs/api/java/util/List.html
对于您来说,您可能希望使用ArrayList<T>,因此:
import java.util.ArrayList;
...
List<ItemInterface> interfaceList = new ArrayList<ItemInterface>();https://stackoverflow.com/questions/7664986
复制相似问题