-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForLoop3.java
More file actions
30 lines (27 loc) · 817 Bytes
/
ForLoop3.java
File metadata and controls
30 lines (27 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* c. Labeled for loop:
* We can have name of each for loop. To do so, we use label before the for loop.
* It is useful if we have nested for loop so that we can break/continue specific for loop.
* Normally, break and continue keywords breaks/continues the inner most for loop only.
*
* Syntax:
* label name:
* for(initialization;condition;increment/decrement){
* //code to be executed.
* }
*/
public class ForLoop3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
aa:
for (int i=1;i<=3;i++) {
bb:
for(int j = 1; j<=3;j++) {
if(i==2&&j==2) {
break aa;
}
System.out.println(i+" "+j);
}
}
}
}