summaryrefslogtreecommitdiffhomepage
path: root/java.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'java.html.markdown')
-rw-r--r--java.html.markdown17
1 files changed, 14 insertions, 3 deletions
diff --git a/java.html.markdown b/java.html.markdown
index 35ec57d8..c2c1a18b 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");
@@ -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.
@@ -320,7 +331,7 @@ public class LearnJava {
// Starting in Java 7 and above, switching Strings works like this:
String myAnswer = "maybe";
- switch(myAnswer){
+ switch(myAnswer) {
case "yes":
System.out.println("You answered yes.");
break;