userimage

“continue” keyword how does it work?

In our project "continue" keyword  is used.But  i did not get the how that logic is working.So first i want to know the continue use.


userimage

A continue statement without a label will re-execute from the condition the innermost while or do loop, and from the update expression of the innermost for loop. It is often used to early-terminate a loop's processing and thereby avoid deeply-nested if statements. In the following example continue will get the next line, without processing the following statement in the loop.


for (int i = 0; i < size.length(); i++)
  continue;


userimage

Basically continue is used to skip present iteration and continue with next iterations 

For example:

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

{

     if(i==5)

     continue;

     System. out.print(i);

}

  Output: 012346789

Here you can see iteration with i=5 is stopped in the middle i.e, at 'continue' statement and remaining iterations are continued as usual.



Answer is