Skip to Content

Do While loop Example

  • 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.

  1. /*
  2.   Do While loop Example
  3.   This Java Example shows how to use do while loop to iterate in Java program.
  4. */
  5.  
  6. public class DoWhileExample {
  7.  
  8.   public static void main(String[] args) {
  9.    
  10.     /*
  11.      * Do while loop executes statment until certain condition become false.
  12.      * Syntax of do while loop is
  13.      *
  14.      * do
  15.      *   <loop body>
  16.      * while(<condition>);
  17.      *
  18.      * where <condition> is a boolean expression.
  19.      *
  20.      * Please not that the condition is evaluated after executing the loop body.
  21.      * So loop will be executed at least once even if the condition is false.
  22.      */
  23.  
  24.     int i =0;  
  25.    
  26.     do
  27.     {
  28.       System.out.println("i is : " + i);
  29.       i++;
  30.      
  31.     }while(i < 5);
  32.    
  33.   }
  34. }
  35.  
  36. /*
  37. Output would be
  38. i is : 0
  39. i is : 1
  40. i is : 2
  41. i is : 3
  42. i is : 4
  43. */