I read on http://www.leepoint.net/notes-java/flow/loops/foreach.html. the for each equivalent to
for (int i = 0; i < arr.length; i++) {
type var = arr[
My question is how does a for each loop work for an empty list
ForEach
also works in the same way. If the length is zero then loop is never executed.
The only difference between them is use ForEach
loop when you want to iterate all the items of the list or array whereas in case of normal for
loop you can control start and end index.