Skip to content

Commit 28b493f

Browse files
committed
feat: Demonstrate use of break in while loop to stop iteration at specific condition
🧠 Logic: - Starts printing numbers from 0 using a `while` loop. - When the counter `i` reaches 500, the `break` statement terminates the loop immediately. - Prints "Break and Continue" after exiting the loop. Signed-off-by: Somesh diwan <[email protected]>
1 parent 6a77f80 commit 28b493f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Section7ConditionalStatements/src/Break.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
public class Break {
22
public static void main(String[] args) {
33
int i =0;
4-
while(i<10000){
4+
5+
while(i<10000) {
56
System.out.println(i);
6-
if(i==500){
7+
8+
if(i==500) {
79
break;
810
}
911
i++;

0 commit comments

Comments
 (0)