Loops/Foreach

From Rosetta Code
Revision as of 02:10, 13 April 2008 by rosettacode>Mwn3d (Created task with Java)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Loops/Foreach
You are encouraged to solve this task according to the task description, using any language you may know.

Loop through and print each element in a collection in order. Use your language's "for each" loop if it has one, otherwise iterate through the collection in order with some other loop.

Java

Works with: Java version 1.5+

<java>Collection<Type> collect; ... for(Type i:collect){

  System.out.println(i);

}</java>