Top "Foreach" questions

foreach is a looping construct that executes a given piece of code for each element in a list/collection/array.

Which is more efficient, a for-each loop, or an iterator?

Which is the most efficient way to traverse a collection? List<Integer> a = new ArrayList<Integer>(); …

java collections foreach
What does the colon (:) operator do?

Apparently a colon is used in multiple ways in Java. Would anyone mind explaining what it does? For instance here: …

java for-loop foreach operators colon
C#, Looping through dataset and show each record from a dataset column

In C#, I'm trying to loop through my dataset to show data from each row from a specific column. I …

c# foreach dataset
How to remove element from array in forEach loop?

I am trying to remove an element in an array in a forEach loop, but am having trouble with the …

javascript foreach
Possible to iterate backwards through a foreach?

I know I could use a for statement and achieve the same effect, but can I loop backwards through a …

c# foreach
c# foreach (property in object)... Is there a simple way of doing this?

I have a class containing several properties (all are strings if it makes any difference). I also have a list, …

c# properties foreach generic-list
How does the enhanced for statement work for arrays, and how to get an iterator for an array?

Given the following code snippet: int[] arr = {1, 2, 3}; for (int i : arr) System.out.println(i); I have the following questions: …

java arrays iterator foreach
Using Python to execute a command on every file in a folder

I'm trying to create a Python script that would : Look into the folder "/input" For each video in that folder, …

python foreach mencoder
I have 2 dates in PHP, how can I run a foreach loop to go through all of those days?

I'm starting with a date 2010-05-01 and ending with 2010-05-10. How can I iterate through all of those …

php foreach date