Skip to content

Instantly share code, notes, and snippets.

@ashigeru
Created January 17, 2017 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashigeru/a492be48411d7b5e0e9b8eba64013047 to your computer and use it in GitHub Desktop.
Save ashigeru/a492be48411d7b5e0e9b8eba64013047 to your computer and use it in GitHub Desktop.
break w/ target label in Java
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