1.迭代器在遍歷集合的時候是不依賴索引的
2.迭代器需掌握三個方法:
Iteratorit=list.iterator();
while(it.hasNext()){
String str=it.next();
System.out.println(str);
}
3.迭代器的四個細節:
*如果當前位置沒有元素,還要強行獲取,會報NoSuchElementException
*迭代器遍歷完畢,指針不會復位
*循環中只能用一次next方法
*迭代器遍歷時,不能用集合的方法進行增加或者刪除