From 79008d76c9d6016bdb80d789a4ed0269105a7aab Mon Sep 17 00:00:00 2001 From: Chaitya Shah Date: Fri, 16 Oct 2015 20:49:00 -0400 Subject: Fix Spacing Inconsistency --- java.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 35ec57d8..2395ed0b 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -250,7 +250,7 @@ public class LearnJava { // If statements are c-like int j = 10; - if (j == 10){ + if (j == 10) { System.out.println("I get printed"); } else if (j > 10) { System.out.println("I don't"); -- cgit v1.2.3 From 9f822a0a25776f1c3d384da31970fa33301f3b3c Mon Sep 17 00:00:00 2001 From: Akshay Kalose Date: Fri, 16 Oct 2015 21:03:46 -0400 Subject: Add For Loop Label Breaking in Java --- java.html.markdown | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'java.html.markdown') diff --git a/java.html.markdown b/java.html.markdown index 35ec57d8..6aff5b6f 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -285,7 +285,18 @@ public class LearnJava { // Iterated 10 times, fooFor 0->9 } System.out.println("fooFor Value: " + fooFor); - + + // Nested For Loop Exit with Label + outer: + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + if (i == 5 && j ==5) { + break outer; + // breaks out of outer loop instead of only the inner one + } + } + } + // For Each Loop // The for loop is also able to iterate over arrays as well as objects // that implement the Iterable interface. -- cgit v1.2.3