Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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