Created
January 17, 2017 01:33
-
-
Save ashigeru/a492be48411d7b5e0e9b8eba64013047 to your computer and use it in GitHub Desktop.
break w/ target label in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BreakExample { | |
public static void main(String... args) { | |
boolean always = true; | |
String message; | |
body: | |
{ | |
if (always) { | |
message = "OK"; | |
// http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.15 | |
break body; | |
} | |
message = "after break"; | |
} | |
System.out.println(message); // -> "OK" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment