python中的LinkedHashSet替代

livikmap99
Iterator i1=h1.iterator();
while(i1.hasNext()){
int p=(int)(i1.next());
}

请用python编程语言术语解释此代码,这里h1是linkedhashset预先感谢

安德列斯·萨科(Andres Sacco)

您有不同的方法来迭代“ LinkedHashSet”,例如,使用:“ forEach”或“ iterate”。

迭代器是一个对象,可用于迭代集合中的所有元素。迭代器有两个重要的方法(hasNext,next)。

我对您的代码的每一行都做了解释

Iterator i1 = h1.iterator(); //obtain an iterator of the collection
while(i1.hasNext()) { // Continue iterating because has a next element 
  int p=(int)(i1.next()); //return the next element and parse it to "int"
}

此外,还可以使用Iterator添加或删除元素。

其他资源:

Java迭代器-Geeks for Geeks

Java官方文档

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

python中的替代编码

来自分类Dev

在Python中检测Kwarg替代

来自分类Dev

Python中SQLite的NoSQL替代

来自分类Dev

Python中的替代密码优化

来自分类Dev

在Python中检测Kwarg替代

来自分类Dev

替代Goto,Python中的Label?

来自分类Dev

列表理解可替代Python中的reduce()

来自分类Dev

在Python中合并JSON,替代eval()?

来自分类Dev

在Ubuntu中替换Python的替代版本

来自分类Dev

替代封装在python中的捕获组

来自分类Dev

python中itertools.tee的替代

来自分类Dev

python CNTK中损失函数的替代方法

来自分类Dev

python中嵌套for循环的替代方法

来自分类Dev

python 3中zip的替代品?

来自分类Dev

在域模型中定义LinkedHashSet的最佳方法

来自分类Dev

LinkedHashSet <ItemCategory>和Android中的微调器

来自分类Dev

如何替换LinkedHashSet中的特定元素?

来自分类Dev

linkedHashSet中重复的项目的索引

来自分类Dev

Java中python的dir()的替代方法是什么?

来自分类Dev

替代Python 3中的M2Crypto的EVP

来自分类Dev

用替代值替换Python字符串中的“令牌”

来自分类Dev

Python 3.5中urllib.urlretrieve的替代方法

来自分类Dev

用.isin()熊猫测试的列中的替代值(python)

来自分类Dev

python中list.extend的替代方法/更快的方法?

来自分类Dev

迭代以在python中获取大小写替代

来自分类Dev

python中SAS格式的替代方法是什么?

来自分类Dev

替代Python 2.7和3.6中的命令库

来自分类Dev

python / django中巨型Heredoc的上下文替代

来自分类Dev

根据Python中R函数的替代因素进行拆分