使用迭代器时如何获取当前循环索引? [英] How to get the current loop index when using Iterator?

查看:34
本文介绍了使用迭代器时如何获取当前循环索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个迭代器来遍历一个集合我想获取当前元素的索引.

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.

这篇关于使用迭代器时如何获取当前循环索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆