Given this Code
import java.util.Iterator;
private static List someList = new ArrayList();
public static void main(Strin
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.
The only way I can get those two exact errors is to call my class Iterator
. I suppose this would be an easy mistake to make if you were writing a little test class about iteration:
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
public class Iterator {
private static List<String> someList = new ArrayList<String>();
public static void main(String[] args) {
someList.add("monkey");
someList.add("donkey");
for (Iterator<String> i = someList.iterator(); i.hasNext();) {
String item = i.next();
System.out.println(item);
}
}
}
Solution: don't do that. Call it something else.
As fun as it is to try and guess what your code looked like, had you posted an entire example in your question this would have been a shorted process. I'm not ruling out that there's another code sample that produces those errors, although I failed to find one with a bit of experimentation.
check your import statement proper it may be possible that you have already import iterator that comes from another packages first organize your imports delete those imports and add
import java.util.Iterator;
hope it will works for you