Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法实例化类型迭代器<;ArrayList<;整数>&燃气轮机; ArrayList-wordIndex=new-ArrayList(Collections.nCopies(initWord.length(),null)); //填充它。 迭代器iterWordIndex=新迭代器();_Java_Arraylist_Iterator_Instantiation - Fatal编程技术网

Java 无法实例化类型迭代器<;ArrayList<;整数>&燃气轮机; ArrayList-wordIndex=new-ArrayList(Collections.nCopies(initWord.length(),null)); //填充它。 迭代器iterWordIndex=新迭代器();

Java 无法实例化类型迭代器<;ArrayList<;整数>&燃气轮机; ArrayList-wordIndex=new-ArrayList(Collections.nCopies(initWord.length(),null)); //填充它。 迭代器iterWordIndex=新迭代器();,java,arraylist,iterator,instantiation,Java,Arraylist,Iterator,Instantiation,为什么我不能这样做 ArrayList<ArrayList<Integer>> wordIndex = new ArrayList<ArrayList<Integer>>(Collections.<ArrayList<Integer>>nCopies(initWord.length(), null)); // Populate it. Iterator<ArrayList<Integer>> i

为什么我不能这样做

ArrayList<ArrayList<Integer>> wordIndex = new ArrayList<ArrayList<Integer>>(Collections.<ArrayList<Integer>>nCopies(initWord.length(), null)); 

// Populate it.

Iterator<ArrayList<Integer>> iterWordIndex = new Iterator<ArrayList<Integer>>(); 
无法实例化类型迭代器

因为迭代器是一个接口。您不能创建它的实例。您需要创建一个实现该接口的具体类的实例(但大多数情况下,您只是从现有集合中获得一个引用)。

因为迭代器是一个接口。您不能创建它的实例。您需要创建一个实现该接口的具体类的实例(但大多数情况下,您只能从现有集合中获取引用)。

您不能实例化
迭代器,因为
迭代器
是一个接口。您只能实例化具体的类。在这种情况下,让
ArrayList
为您生成一个:

 Cannot instantiate the type Iterator<ArrayList<Integer>>
Iterator iterWordIndex=wordIndex.Iterator();
您不能实例化
迭代器,因为
迭代器是一个接口。您只能实例化具体的类。在这种情况下,让
ArrayList
为您生成一个:

 Cannot instantiate the type Iterator<ArrayList<Integer>>
Iterator iterWordIndex=wordIndex.Iterator();