package workhome; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class ListDemo { public static void main(String[] args) { //定义集合list List<String> list=new ArrayList<String>(); Iterator<String> it=list.iterator(); //通过迭代器访问 while(it.hasNext()) { String s=it.next(); System.out.println(s); } } }