-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_break.java
More file actions
36 lines (34 loc) · 808 Bytes
/
java_break.java
File metadata and controls
36 lines (34 loc) · 808 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
31
32
33
34
35
36
public class java_break {
public static void main(String[] args) {
/// Break and continue in for loops
for (int i = 0; i < 10; i++) {
if(i == 4) {
break;
}
System.out.println(i);
}
for (int i = 0; i < 10; i++) {
if (i == 4){
continue;
}
System.out.println(i);
}
/// Break and Continue in While loop
int i = 0;
while (i < 10) {
System.out.println(i);
i++;
if (i == 4) {
break;
}
}
while (i < 10) {
if (i == 4) {
i++;
continue;
}
System.out.println(i);
i++;
}
}
}