package test;
import java.util.ArrayList;
import java.util.Iterator;
public class TestIterator {
public static void main(String[] args) {
ArrayList<String> al = new ArrayList<>();
al.add("a");
al.add("b");
al.add("c");
al.add("d");
al.add("e");
Iterator<String> it = al.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
}
}
|
|