JAVA LISTITERATORS

问题描述 投票:0回答:1

即使在if语句中,是否使用iterator.next()将其移至下一个?

java iterator
1个回答
0
投票

是的,即使在if条件内使用,next()方法也始终前进到下一个值。下面是方法说明,

 /**
 * Returns the next element in the iteration.
 *
 * @return the next element in the iteration
 * @throws NoSuchElementException if the iteration has no more elements
 */
 E next();
© www.soinside.com 2019 - 2024. All rights reserved.