July 26, 2011, 10:32 p.m.
posted by freeheart
The foreach Statement
The foreach statement allows you to iterate through all the items in an array or other collection, examining each item in turn. The syntax for the foreach statement is:
foreach (type identifier in expression) statement
You can update Figure to replace the final two for statements (that iterate over the contents of the populated array) with foreach statements, as shown in Figure.
The output will be identical.