summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Morgan <sjm@sjm.io>2015-05-23 12:51:20 +0100
committerSimon Morgan <sjm@sjm.io>2015-05-23 12:51:20 +0100
commit7560b334dbc528784580d810d5857ac6a859f6e1 (patch)
tree35488d859503b24423f3581044f695ca4a17094d
parentb72c575c0442006c4eed1da46e1f6a0129f55d99 (diff)
Improve description of the for loop.
-rw-r--r--java.html.markdown9
1 files changed, 5 insertions, 4 deletions
diff --git a/java.html.markdown b/java.html.markdown
index f6bc82c6..7ab22823 100644
--- a/java.html.markdown
+++ b/java.html.markdown
@@ -225,11 +225,12 @@ public class LearnJava {
System.out.println("fooFor Value: " + fooFor);
// For Each Loop
- // An automatic iteration through an array or list of objects.
+ // The for loop is also able to iterate over arrays as well as objects
+ // that implement the Iterable interface.
int[] fooList = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- // for each loop structure => for (<object> : <array_object>)
- // reads as: for each object in the array
- // note: the object type must match the array.
+ // for each loop structure => for (<object> : <collection>)
+ // reads as: for each element in the collection
+ // note: the object type must match the element type of the collection.
for (int bar : fooList) {
System.out.println(bar);