即使在if语句中,是否使用iterator.next()将其移至下一个?
是的,即使在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();