如下有一list集合:

List<String> list = new ArrayList<String>( "a","b","c","d");

//方法1 用迭代器遍历

Iterator it = list.iterator();

while(it.hasNext()){

  System.out.println(it.next());

}

//方法2 增强型for循环遍历

for(String value:list){

System.out.println(value);

}

//方法3 一般型for循环遍历

for(int i = 0;i < list.size(); i ++){

System.out.println(list.get(i));

}