public Iterator iterator()
public ListIterator listIterator()
public ListIterator listIterator(int index)
Using an iterator from a List is like using any other iterator.
The order of the elements in the list is preserved.
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class MainClass {
public static void main(String[] a) {
List list = Arrays.asList(new String[] { "A", "B", "C", "D" });
Iterator iter = list.iterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
}
}
A
B
C
D