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","java2s.com").iterator(); while (it.hasNext()) { String key = it.next().toString(); System.out.println(key); } } }
The code above generates the following result.