使用Iterator时如何获取当前循环索引? [英] How to get the current loop index when using Iterator?
本文介绍了使用Iterator时如何获取当前循环索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用迭代器迭代一个集合
,我想得到当前元素的索引。
I am using an Iterator to iterate through a collection and I want to get the current element's index.
我该怎么做?
推荐答案
使用你自己的变量并在循环中增加它。
Use your own variable and increment it in the loop.
这篇关于使用Iterator时如何获取当前循环索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文