Skip to Content

Continue Statement

  • strict warning: Non-static method view::load() should not be called statically in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/views.module on line 906.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_argument.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter_boolean_operator.inc on line 0.
  • strict warning: Declaration of views_plugin_style_default::options() should be compatible with views_object::options() in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_style_default.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_row.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_row.inc on line 0.

Continue statement is used when we want to skip the rest of the statement in the body of the loop and continue with the next iteration of the loop.
There are two forms of continue statement in Java.

1. Unlabeled Continue Statement
2. Labeled Continue Statement

Unlabeled Continue Statement

This form of statement causes skips the current iteration of innermost for, while or do while loop.

For example,

  1. for(int var1 =0; var1 < 5 ; var1++)
  2. {
  3.  
  4.         for(int var2=0 ; var2 < 5 ; var2++)
  5.         {
  6.                 if(var2 == 2)
  7.                         continue;
  8.  
  9.                         System.out.println(“var1:+ var1 + “, var2:+ var2);
  10.  
  11.         }
  12.  
  13. }

In above example, when var2 becomes 2, the rest of the inner for loop body will be skipped.

Labeled Continue Statement

Labeled continue statement skips the current iteration of the loop marked with the specified label. This form is used with nested loops.

For example,

  1. Outer:
  2. for(int var1 =0; var1 < 5 ; var1++)
  3. {
  4.  
  5.         for(int var2=0 ; var2 < 5 ; var2++)
  6.         {
  7.                 if(var2 == 2)
  8.                         continue Outer;
  9.  
  10.                 System.out.println(“var1:+ var1 + “, var2:+ var2);
  11.  
  12.         }
  13.  
  14. }

In the above example, when var2 becomes 2, rest of the statements in body of inner as well outer for loop will be skipped, and next iteration of the Outer loop will be executed.

Continue Statement Examples