march articles code review

This commit is contained in:
Mayank Agarwal
2023-03-18 09:37:04 +05:30
parent 44bb31c1d6
commit 5f09e78f92
2 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import java.util.*;
public class JavaContinue {
public static void main(String[] args) {
int i = 0;
while (i < 10) {
if (i == 5) {
break;
}
System.out.println(i);
i++;
}
}
public static void breakExample(String[] args) {
int[][] numbers = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
outer: for (int i = 0; i < numbers.length; i++) {
for (int j = 0; j < numbers[i].length; j++) {
if (numbers[i][j] == 5) {
System.out.println("Found 5 at index [" + i + "][" + j + "]");
break outer;
}
}
}
}
}