本文介紹了迭代器和Listiterator的區(qū)別?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
Iterator ite = Set.iterator();
Iterator ite = List.iterator();
ListIterator listite = List.listIterator();
我們可以使用Iterator
來(lái)遍歷Set
或List
或Map
.但是ListIterator
只能用來(lái)遍歷List
,不能遍歷Set
.為什么?
We can use Iterator
to traverse a Set
or a List
or a Map
. But ListIterator
can only be used to traverse a List
, it can't traverse a Set
. Why?
我知道主要區(qū)別在于,使用迭代器我們只能在一個(gè)方向上移動(dòng),而使用 ListIterator
我們可以雙向移動(dòng).還有其他區(qū)別嗎?ListIterator
比 Iterator
有什么優(yōu)勢(shì)?
I know that the main difference is that with iterator we can travel in only one direction but with ListIterator
we can travel both directions. Are there any other differences? And any advantages of ListIterator
over Iterator
?
推薦答案
ListIterator
你可以
- 向后迭代
- 隨時(shí)獲取迭代器.
- 隨時(shí)添加新值.
- 此時(shí)設(shè)置一個(gè)新值.
這篇關(guān)于迭代器和Listiterator的區(qū)別?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!