forked from dimpeshpanwar/javabasicprograms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BreakAndContinue24.java
37 lines (26 loc) · 1.09 KB
/
BreakAndContinue24.java
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
package Looping;
public class BreakAndContinue24 {
public static void main(String[] args) {
// Break and Continue using loops
// ********************************** break : to exit the loop ********************************************
for(int i=0; i<5; i++){
if(i==2){
System.out.println("Ending the loop");
break;
}
System.out.println(i);
System.out.println("Java is great");
}
System.out.println("Loop ends here");
//****************** continue : terminate the specific iteration and continue the loop further *************
// for(int i=0; i<5; i++){
// if(i==2){
// System.out.println("Skipping this iteration here");
// continue;
// }
// System.out.println(i);
// System.out.println("Java is great");
// }
// System.out.println("Loop ends here");
}
}