Computer Science, asked by nitishamadeshiya, 11 months ago

what is the purpose of using continue statement in Java programming

Answers

Answered by amitkumar502
4
The continue statement skips the current iteration of a loop (for, while, and do...while loop).

When continue statement is executed, control of the program jumps to the end of the loop. Then, the test expression that controls the loop is evaluated. In case of for loop, the update statement is executed before the test expression is evaluated.

It is almost always used with decision making statements (if...else Statement).



amitkumar502: if you like mark as BRILLIANT
Answered by Anonymous
4

Hey mate here is your answer:

___________________________________________

Continue statement

The continue is an example of a jump statement.

It is exactly the opposite of the break statement.

The break statements terminates the loop when executed.

When the continue statement is executed it continues the loop without moving further.

Example

class continue_explained

{

public void main()

{

int a = 1;

int b = 3;

int c=0;

for( int i = 0;i< 3; i++)

{

if(i==1)

{

continue;

}  

else

{

c=a*b;

a++;

}

}

System.out.println(c);

}

}

Output

6

Explanation

First i is 0

c = 1*3 = 3

a++ a becomes 2

i ++ i becomes 1

continue is applied .

so loop continues.

i++ i becomes 2

c=2*3

=6

a++ a becomes 3

i++ i becomes 3

3<3 condition false so loop terminates.

The output is c which is 6.

Hope it helps you

____________________________________________________________________


Similar questions