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

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

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

問題描述

我對迭代器上的 next() 方法有疑問.如果我將這行代碼作為我的代碼的一部分(使用 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);
}

在第一次迭代時,迭代器開始指向索引為 0 的元素?還是像索引-1"?

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

我問是因為據(jù)我所知 next() 方法返回集合中的下一個元素.

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

所以,如果在第一次迭代中,當調(diào)用 next() 時迭代器從索引 0 開始,它會返回索引 1 處的元素,我將無法對索引為 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 視為一個兩步過程.首先它獲取迭代器中的下一項,然后遞增指針以指向下一項.因此,當您創(chuà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.

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

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

相關文檔推薦

Java Remove Duplicates from an Array?(Java從數(shù)組中刪除重復項?)
egit plugin for Eclipse(Eclipse 的 egit 插件)
Gitlab cannot open git-upload-pack error(Gitlab 無法打開 git-upload-pack 錯誤)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復調(diào)用失敗來自服務器的意外響應:在 Android 工作室中未經(jīng)授權)
How to add GitLab repository in Eclipse?(如何在 Eclipse 中添加 GitLab 存儲庫?)
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
主站蜘蛛池模板: 国产精品乱码一区二区三区 | 特一级黄色毛片 | 欧美不卡视频 | www.久久.com | 久久尤物免费一区二区三区 | 美女一区 | 日韩二区 | 免费在线观看黄网站 | 中文在线一区 | 日韩有码一区二区三区 | 999久久久免费精品国产 | 欧美又大粗又爽又黄大片视频 | 在线免费黄色小视频 | 日韩欧美成人精品 | 精品亚洲91| 国产精品久久久亚洲 | 成人h片在线观看 | 国产精品日韩欧美一区二区 | 久久久久久久久久久久91 | 精品中文字幕一区二区三区 | 久久久青草婷婷精品综合日韩 | 免费精品久久久久久中文字幕 | 国产露脸国语对白在线 | 狠狠插天天干 | 日本视频一区二区 | 亚洲黄色视屏 | 久久精品二区 | 国产日产精品一区二区三区四区 | 国产一区二区三区在线免费 | 久久久蜜桃一区二区人 | 国产精品精品3d动漫 | 在线观看免费av片 | 丁香六月伊人 | 伊人成人免费视频 | 91久久精品一区二区二区 | 新超碰97 | 国产视频在线观看一区二区三区 | 成人国产精品免费观看 | www.天天操 | 国产精品视频在线观看 | 中文字幕在线免费观看 |