Last active
June 23, 2025 00:47
-
-
Save pethaniakshay/2015b7ec6081667b7fdc74fde50c186e to your computer and use it in GitHub Desktop.
Example of Labeled For Loop 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 LabeledForLoop{ | |
public static void main(String args[]){ | |
outer_loop: | |
for(int i=0 ; i<5 ; i++){ | |
inner_loop: | |
for(int j=0 ; j<5 ; j++){ | |
if(i==2 || j ==4){ | |
break outer_loop; | |
} | |
else{ | |
System.out.print(i + "-"+ j + " "); | |
} | |
} | |
System.out.println(); | |
} | |
} | |
} |
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 SimpleForLoop{ | |
public static void main(String args[]){ | |
for(int i=0 ; i<5 ; i++){ | |
for(int j=0 ; j<5 ; j++){ | |
if(i==2 || j ==4){ | |
break; | |
} | |
else{ | |
System.out.print(i + "-"+ j + " "); | |
} | |
} | |
System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment