java looping through a list code example
Example 1: java loop through list
for (E element : list) {
. . .
}
Example 2: java iterate over list
for (int i = 0; i < crunchifyList.size(); i++) {
System.out.println(crunchifyList.get(i));
}
Example 3: 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); }