summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Bard <github@adambard.com>2013-09-08 21:49:26 -0700
committerAdam Bard <github@adambard.com>2013-09-08 21:49:26 -0700
commit599ed0df3012ae578281dd92afc5a48891f56810 (patch)
tree7a3d8f634327c8071563c5cbf1a324b82ea26436
parentf423f54d42f9af9623e3c77f7dfbd30e8f7f9eb6 (diff)
parent995013c92119395564d303a2b6b5e67fcb66a5fc (diff)
Merge pull request #313 from mix3d/patch-1
Including for each loop example
-rw-r--r--java.html.markdown14
1 files changed, 13 insertions, 1 deletions
diff --git a/java.html.markdown b/java.html.markdown
index cdcf620c..a2fc3630 100644
--- a/java.html.markdown
+++ b/java.html.markdown
@@ -210,7 +210,19 @@ public class LearnJava {
//Iterated 10 times, fooFor 0->9
}
System.out.println("fooFor Value: " + fooFor);
-
+
+ // For Each Loop
+ // An automatic iteration through an array or list of objects.
+ 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( int bar : fooList ){
+ //System.out.println(bar);
+ //Iterates 9 times and prints 1-9 on new lines
+ }
+
// Switch Case
// A switch works with the byte, short, char, and int data types.
// It also works with enumerated types (discussed in Enum Types),