I need to figure out the number of elements in an Iterable
in Java.
I know I can do this:
Iterable values = ...
it = values.iterator();
while (i
I would go for it.next()
for the simple reason that next()
is guaranteed to be implemented, while remove()
is an optional operation.
E next()
Returns the next element in the iteration.
void remove()
Removes from the underlying collection the last element returned by the iterator (optional operation).