Viewing topic: For Each Loops

See sub-topics for For Each Loops ... >> Computer Science >> Programming >> For Each Loops

Highest Rated Sign

Video id: #182 (enlarge)
Post date: 5/28/2009
Posted by: rajah
  • Currently 0.0/5 Stars.
  0 ratings
See all signs (1)

For Each Loops

  • Definition: For each (or foreach) is a computer language idiom for traversing items in a collection. Foreach is usually used in place of a standard for statement. Unlike other for loop constructs, however, foreach loops (usually) maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". This can potentially avoid off-by-one errors and make code simpler to read. In object-oriented languages an iterator, even if implicit, is often used as the means of traversal.

    Source: Reges & Stepp, 2007

  • Example: Example sentence for context: "Java 5 introduced a new loop construct that simplifies many certain array loops- it’s known as the enhanced foor loop, or the for-each loop."

  • 9:50am 5/14/2015

    User: reinlessjacklin

    Post count: 368

    Excellent article. I certainly love this website. Continue the good work! Best Swimming Goggles