-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCwh_24_break_and_continue.java
More file actions
51 lines (43 loc) · 1.02 KB
/
Cwh_24_break_and_continue.java
File metadata and controls
51 lines (43 loc) · 1.02 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
package Practice;
public class Cwh_24_break_and_continue {
public static void main(String[]args)
{
for (int i=0;i<=10;i++)
{
System.out.println(i);
System.out.println("Java is Great");
if (i==2)
{
System.out.println("The value of a is 2 means ending the loop");
break;
}
System.out.println("break Keyword is Successfully executed");
}
//Using while
int a = 0;
while(a<=5)
{
System.out.println(a);
System.out.println("Java is Great");
if (a==2)
{
System.out.println("Ending the loop");
break;
}
a++;
}
//using do while loop
int j = 0;
do
{
System.out.println(j);
System.out.println("Java is Great");
if(j==2)
{
System.out.println("End for the loop");
break;
}
j++;
} while(j<=5);
}
}