久久久久久久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" ?

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

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

所以,如果在第一次迭代中,當調用 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 視為一個兩步過程.首先它獲取迭代器中的下一項,然后遞增指針以指向下一項.因此,當您創建一個新的迭代器時,它會被初始化為返回列表中的第一項(索引 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模板網!

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

相關文檔推薦

Java Remove Duplicates from an Array?(Java從數組中刪除重復項?)
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(如何修復調用失敗來自服務器的意外響應:在 Android 工作室中未經授權)
How to add GitLab repository in Eclipse?(如何在 Eclipse 中添加 GitLab 存儲庫?)
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
主站蜘蛛池模板: 国产精品永久久久久久久www | 色av一区 | 国产最好的av国产大片 | 久久av一区二区三区 | 国产精品视频一区二区三区四蜜臂 | 男人天堂免费在线 | 国产激情一区二区三区 | 夜夜骑首页 | 精品国产一区二区三区久久狼黑人 | 午夜av免费 | 五月天国产在线 | 成人区精品 | 91色视频在线观看 | 亚洲色图图片 | 欧美性生活网 | 久久精品美女 | 亚洲视频一区在线观看 | 国产一级视频在线播放 | 国产xxxx岁13xxxxhd| 成人动漫视频网站 | 免费一看一级毛片 | 欧美日韩亚洲国产 | 成人精品免费视频 | 91视频播放| 国产精品久久久久一区二区三区 | 国产一区久久精品 | 国产激情一区二区三区 | 伊人久久免费 | 亚洲一区在线播放 | 特级黄色毛片 | 国产精品久久久久久一区二区三区 | 在线免费观看黄色网址 | 麻豆久久精品 | 日韩中文字幕在线观看 | 国产精品99久久久久久动医院 | 欧美一区二区在线播放 | 中文字幕在线观看第一页 | 国产专区在线 | 日本公妇乱淫xxxⅹ 国产在线不卡 | 国产美女一区二区 | 日韩高清一区二区 |