java集合中next()和hasNext()之间的不同 [英] Differnce between next() and hasNext() in java collections
本文介绍了java集合中next()和hasNext()之间的不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新的java和我正在通过集合,在迭代他们使用 next()
和 hasNext()
方法。这两个方法究竟做什么?什么时候我必须使用 next()
和 hasNext()
?
I am new to java and I was going through collections and during the iteration they have used next()
and hasNext()
methods. What exactly does these two methods do? When do I have to use next()
and hasNext()
?
推荐答案
hasNext()
将返回true it iteration has more values
next()
返回迭代中的下一个元素
hasNext()
will return true it iteration has more values and
next()
returns the next element in iteration
这篇关于java集合中next()和hasNext()之间的不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文