Java Collection Tutorial - Java List.iterator()


List.iterator() has the following syntax.

Iterator < E > iterator()


In the following code shows how to use List.iterator() method.

//from   w ww  . j  a  va 2 s  .  c o m
import java.util.Arrays;
import java.util.Iterator;

public class Main {
  public static void main(String[] args) throws Exception {
    Iterator it = Arrays.asList("a","b","").iterator();
    while (it.hasNext()) {
      String key =;

The code above generates the following result.