diff options
author | Geoff Liu <cangming.liu@gmail.com> | 2015-05-26 13:12:05 -0600 |
---|---|---|
committer | Geoff Liu <cangming.liu@gmail.com> | 2015-05-26 13:12:05 -0600 |
commit | bb7560f63e06534617e0ab2411ef33e7e3edf5d6 (patch) | |
tree | 0a250728e0fe6122ff15bf4af1e5f36af29dd73e | |
parent | 839c56023b874cbb5dc28493b8e5563e49a5090d (diff) | |
parent | 5214f0ef0ff246928492c9e3bd7c2506420f5134 (diff) |
Merge pull request #1115 from drguildo/master
Improve description of the for loop.
-rw-r--r-- | java.html.markdown | 9 |
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); |