-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathj27BreakAndContinue.java
More file actions
37 lines (34 loc) · 1023 Bytes
/
j27BreakAndContinue.java
File metadata and controls
37 lines (34 loc) · 1023 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
37
public class j27BreakAndContinue {
public static void main(String[] args)
{
System.out.println("__Beak in Java__");
// Break use to end the loop
System.out.println("if i == 2 then loop is breaak ");
int i = 10;
while(i<=10)
{
System.out.println(i);
if (i==2)
{
System.out.println("i == 2 so loop breaked");
break;
}
i--;
}
System.out.println("Continue in java");
// continue stop the iteration and execute next iteration
System.out.println("if j == 2 then loop is breaak ");
int j = 10;
while(j<=10 && j>= -10)
{
if (j==2)
{
System.out.println("j == 2 so loop Continued down task not executed");
j--;
continue;
}
System.out.println(j);
j--;
}
}
}