java util iterator but cannot import java.util.iterator

Posted by qwertzuiop13 on Stack Overflow See other posts from Stack Overflow or by qwertzuiop13
Published on 2014-06-05T15:19:28Z Indexed on 2014/06/05 15:24 UTC
Read the original article Hit count: 373

Filed under:
|

Given this Code

import java.util.Iterator;

private static List<String> someList = new ArrayList<String>();

public static void main(String[] args) {

    someList.add("monkey");
    someList.add("donkey");

    //Code works when I change Iterator to java.util.Iterator, but import      
    //is not possible?
    for(Iterator<String> i = someList.iterator(); i.hasNext(); ) {
        String item = i.next();
        System.out.println(item);
    }

}

I receive the error: The type Iterator is not generic; it cannot be parameterized with arguments

Eclipse tells me that the import java.util.iterator conflicts with a type defined in the same file. lol... ?

© Stack Overflow or respective owner

Related posts about java

Related posts about iterator