Java List.iterator()
Syntax
List.iterator() has the following syntax.
Iterator < E > iterator()
Example
In the following code shows how to use List.iterator() method.
//from www. j a v a2 s . com
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.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »