list length in jav a for loop code example
Example 1: java loop through list
for (E element : list) {
. . .
}
Example 2: how to loop through a list
List<int> list = new List<int> { 1, 2, 3, 4, 5 };
//For Loop
for (int i = 0; i < list.Count(); i++)
{ Console.WriteLine(list[i]); }
//For Each Loop
foreach (int item in list)
{ Console.WriteLine(item); }