Skip to content

Instantly share code, notes, and snippets.

@Kaushal28
Last active July 16, 2019 05:38
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 Kaushal28/42e9c7a208755c46a37e35795c15ccb3 to your computer and use it in GitHub Desktop.
Save Kaushal28/42e9c7a208755c46a37e35795c15ccb3 to your computer and use it in GitHub Desktop.
public class LabelsExample {
public static void main (String[] args) {
//Labels with break; Similar functionality like goto
outerLoop:
for (int i=0;i<10;i++) {
for (int j=0;j<10;j++) {
if (j == 1) {
System.out.println(j);
break outerLoop;
}
}
}
//Labels with continue;
outerLoop1:
for (int i=0;i<10;i++) {
for (int j=0;j<10;j++) {
if (j == 1) {
System.out.println(j);
continue outerLoop1;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment