It is used in any looping statement. It is also used to continue the execution of the current looping statement and it skips the other statement written in the current block after the continue statement.

If continue will be written in while / do-while block then control will be transferred to the conditional statement.

Syntax for continue keyword :
continue ;   or   continue < label > ;

< label > : It indicates that which loop execution will be continued in the current nesting block.

ab:                                                       // Here ab is a label for " for " loop.
for ( int i = 0 ; i < = 10 ; i ++ ) { }


ab1 :
for ( int i = 0 ; i < = 10 ; i ++ ) { 
ab2 :
for ( int j = 0 ; j < = 10 ; j ++ ) { 
ab3 :
for ( int k = 0 ; k < = 10 ; k ++ ) { 
continue ;                            // Continue the current block k and control transferred to k++.
continue ab3 ;                      // Continue the current block k and control transferred to k++.
continue ab2 ;                     //  Continue the current block j and control transferred to j++.
continue ab1 ;                    //   Continue the current block i and control transferred to i++.
}

Use of continue with label 

Let suppose we have multiple array with some value and we want to find some value i.e 34 is available or not  then we need to go for nested loop.  If we found 34 in any one array and then we need to find other values is the same array, then we can continue with next array and hence we can use here continue with label.

Related Posts:

  • If Statement in Java As we know that " if " is a conditional control statement and maximum it will execute once depending upon the condition check. If the condition is true then it will execute once and if false then will not execute at even fo… Read More
  • " for " Looping statement Any looping statement is comprises of there stages i.e 1> Initialization                   2> Conditional                   &n… Read More
  • " while " looping statement " while " statement is also used as the looping statement in any programming languages. It only works with the condition and we can use updation statement inside the block otherwise it will go for infinite loop if the condit… Read More
  • Switch control statement In programming languages switch is a type of conditional control statement. It has one switch statement and many cases with one default statement. Depending upon the switch value it matches with the cases value and execute … Read More
  • " break " control statement break statement is used to control the transfer out the block without executing the statements written after break statement . It is used either with switch or looping statement. Syntax of break statement : break ;  or… Read More

0 comments:

Post a Comment

Blog Archive

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

201976

Online Members

Live Traffic