From 995013c92119395564d303a2b6b5e67fcb66a5fc Mon Sep 17 00:00:00 2001 From: Madison Dickson Date: Wed, 4 Sep 2013 11:30:44 -0400 Subject: Including for each loop example --- java.html.markdown | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'java.html.markdown') 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( : ) + //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), -- cgit v1.2.3