type Iterator does not take parameters

Posted jiangfeilong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了type Iterator does not take parameters相关的知识,希望对你有一定的参考价值。

在ubuntu编译java程序时报错:type Iterator does not take parameters

源码如下:

package object;
import java.util.*;
class Generate{
    Map<Integer,String> map = new HashMap<Integer, String>();
    {
        map.put(1,"mother");
        map.put(2,"wife");
        map.put(3,"father");
    }
    public String next()
    {
        Random rand = new Random();
        int i = rand.nextInt(2) + 1; 
        return map.get(i);
    }
}

public class Iterator1{
    public static void main(String[] args)
    {
        Generate g = new Generate();
        Collection<String> cll = new ArrayList<String>();
        for( int i = 0; i < 10; i++)
            cll.add(g.next());
        Iterator<String> iterator = cll.iterator();
        while(iterator.hasNext())
            System.out.println(iterator.next());
        System.out.println();
    }
}

报错原因:包里面有之前编写的一个Iterator类,编译时优先调用了包里的Iterator而没有调用java.util里面的Iterator

以上是关于type Iterator does not take parameters的主要内容,如果未能解决你的问题,请参考以下文章

[WPF]The type name ‘App’ does not exist in the type '...'的问题

Type mytableview does not confirm to portocol UITableViewDataResource

Input ‘filename‘ of ‘ReadFile ‘Op has type float32 that does not match expected type of string

Go: invalid operation - type *map[key]value does not support indexing

Input ‘filename‘ of ‘ReadFile ‘Op has type float32 that does not match expected type of string

[ts] Property 'aaa' does not exist on type 'Window' 解决办法