-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBreak_and_Contiinue.java
More file actions
97 lines (72 loc) · 2.28 KB
/
Copy pathBreak_and_Contiinue.java
File metadata and controls
97 lines (72 loc) · 2.28 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
public class Break_and_Contiinue {
public static void main(String[] args) {
// Break and Continue using loops
// Break Statement----------------------------------------------------
//(For loop)
for(int i=0; i<=50; i++){
System.out.println(i);
System.out.println("java is great programing");
if(i==2){
System.out.println("Ending the loop");
break;
}
}
//(while loop)
int l=0;
while(l<5) {
System.out.println(l);
System.out.println("java is great programing");
if (l == 2) {
System.out.println("Ending the loop");
break;
}
l++;
}
System.out.println("Loops ends here");
//( Do while loop)
int g=0;
do {
System.out.println(g);
System.out.println("java is great programing");
if (g == 2) {
System.out.println("Ending the loop");
break;
}
g++;
}while(g<5);
System.out.println("Loops ends here");
// Continue Statement------------------------------------------------------
//(For loop)
for(int i=0; i<=50; i++){
if(i==2){
System.out.println("Ending the loop");
continue;
}
System.out.println(i);
System.out.println("java is great programing");
}
//(while loop)
int i=0;
while(i<5) {
i++;
if (i == 2) {
System.out.println("Ending the loop");
continue;
}
System.out.println(i);
System.out.println("java is great programing");
}
//( Do while loop)
int j=0;
do {
j++;
if (j == 2) {
System.out.println("Ending the loop");
continue;
}
System.out.println(j);
System.out.println("java is great programing");
}while(j<5);
System.out.println("Loops ends here");
}
}