I was writing a simple code on iterators, when I started to get this error. It says that ListIterator does not take parameters but I think it does, so what’s wrong
It seems to work fine for String type but not for wrapper classes, what is the reason behind it
import java.util.*;
public class ListIterator {
public static void main(String []argv) {
List<Integer> list = new ArrayList<>();
list.add(10);
list.add(30);
list.add(20);
ListIterator<Integer> it = list.listIterator();
while (it.hasNext()) {
System.out.print(it.next()+" ");
}
}
}