久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

迭代器上的 next() 方法如何工作?

How does next() method on iterators work?(迭代器上的 next() 方法如何工作?)
本文介紹了迭代器上的 next() 方法如何工作?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我對(duì)迭代器上的 next() 方法有疑問(wèn).如果我將這行代碼作為我的代碼的一部分(使用 arrayOfStrings size = 4):

I have a doubt with the next() method on iterators. If I have as a part of my code this lines (with arrayOfStrings size = 4):

Iterator<String> it = arrayOfStrings.iterator(); //arrayOfString is ArrayList<String>

while(it.hasNext()) {
    String e = it.next();
    System.out.println(e);
}

在第一次迭代時(shí),迭代器開(kāi)始指向索引為 0 的元素?還是像索引-1"?

At the very first iteration, the iterator starts pointing to element with index 0? or like the "index -1" ?

我問(wèn)是因?yàn)閾?jù)我所知 next() 方法返回集合中的下一個(gè)元素.

I ask because as far as I know the next() method returns the next element in the collection.

所以,如果在第一次迭代中,當(dāng)調(diào)用 next() 時(shí)迭代器從索引 0 開(kāi)始,它會(huì)返回索引 1 處的元素,我將無(wú)法對(duì)索引為 0 的元素?

So, if at the very first iteration the iterator starts at index 0 when next() is invoked, it returns the element at index 1 and I won′t be able to do nothing with the element at index 0?

推薦答案

next 視為一個(gè)兩步過(guò)程.首先它獲取迭代器中的下一項(xiàng),然后遞增指針以指向下一項(xiàng).因此,當(dāng)您創(chuàng)建一個(gè)新的迭代器時(shí),它會(huì)被初始化為返回列表中的第一項(xiàng)(索引 0).

Think of next as a two-step process. First it gets the next item in the iterator, then it increments the pointer to point to the next item. So, when you create a new iterator, it is initialized to return the first item (index 0) in your list.

這篇關(guān)于迭代器上的 next() 方法如何工作?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Java Remove Duplicates from an Array?(Java從數(shù)組中刪除重復(fù)項(xiàng)?)
egit plugin for Eclipse(Eclipse 的 egit 插件)
Gitlab cannot open git-upload-pack error(Gitlab 無(wú)法打開(kāi) git-upload-pack 錯(cuò)誤)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復(fù)調(diào)用失敗來(lái)自服務(wù)器的意外響應(yīng):在 Android 工作室中未經(jīng)授權(quán))
How to add GitLab repository in Eclipse?(如何在 Eclipse 中添加 GitLab 存儲(chǔ)庫(kù)?)
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
主站蜘蛛池模板: 国产成人精品久久二区二区91 | 久久久久国产精品一区二区 | 黄片毛片免费观看 | www.亚洲成人网 | 日本电影免费完整观看 | 久草免费在线视频 | 欧美成人h版在线观看 | 青青草免费在线视频 | 成人国产在线视频 | 国产精品久久久久久久久久尿 | 午夜影院网站 | 999国产视频 | 91精品国产日韩91久久久久久 | 九色91视频| 国产精品不卡 | 成人午夜视频在线观看 | 狠狠操电影 | 可以在线看的黄色网址 | 国产精品一区二区三 | 精品亚洲一区二区三区 | 国产h视频 | 成人精品一区 | 日韩有码在线观看 | 欧美一区视频 | 天天操天天操 | 午夜男人的天堂 | 国产精品免费视频一区 | 人人干人人玩 | 狠狠色狠狠色综合日日92 | 人操人人干人 | 成人一区av偷拍 | 99精品国产一区二区三区 | 夜夜干夜夜操 | 天天干天天爱天天操 | 欧美日韩国产精品一区 | 日本免费一区二区三区四区 | 色婷婷亚洲国产女人的天堂 | 久久久成人免费视频 | 性网址| 日韩精品欧美精品 | 久久综合激情 |