Say l1
is a data structure that implements Iterable
, and assertEquals()
was taken from JUnit 5.
I would like to assert that l1
has the elements zero to 99 in order.
How can I do this with a lambda and forEach iterate through l1
?
(The following code returns an error because counter
is not final.)
int counter=0;
l1.forEach(t -> {
assertEquals(counter,t);
counter++;
});