Oopj
Oopj
AND
PROGRAMMING IN JAVA
CONTENTS
“BREAK” vs “CONTINUE”
“BREAK”
What is “Break” Statement ?
Syntax of “Break” Statement
Uses of “Break” Statement
Understanding “Break” Statement with the
help of an Example
“CONTINUE”
What is “Continue” Statement ?
Syntax of “Continue” Statement
Uses of “Continue” Statement
Understanding “Continue” Statement with the
help of an Example
continue;
statements..
while (condition);
class dowhile {
public static void main(String[] args)
{
int i = 3;
do {
i++;
System.out.println("dowhile");
} while (i < 10);
}
}
“While” LOOP
What is “While” loop
A while loop is a control flow statement that allows code to be executed repeatedly based on a
given Boolean condition. The while loop can be thought of as a repeating if statement.
class whilee {
public static void main(String[] args)
{
int i = 3;
The break statement is used to terminate the The continue statement is used to skip the
loop immediately. current iteration of the loop.
break keyword is used to indicate break continue keyword is used to indicate continue
statements in java programming. statement in java programming.
We can use a break with the switch We can not use a continue with the switch
statement. statement.
The break statement terminates the whole The continue statement brings the next iteration
loop early. early.
It stops the execution of the loop. It does not stop the execution of the loop.
Variable in condition is initialized before the variable may be initialized before or within the
execution of loop. loop.
while loop is entry controlled loop. do-while loop is exit controlled loop.
while(condition) do { statement(s); }
{ statement(s); } while(condition);