Does anyone know why the java.util.Spliterator
implementation uses do-while rather than while loops, when the body of the loop is empty? For instance, the implementation of forEachRemaining
is:
default void forEachRemaining(Consumer<? super T> action) {
do { } while (tryAdvance(action));
}
Why would they use
do { } while (tryAdvance(action));
instead of
while(tryAdvance(action));
?
Are there any advantages I am not aware of?