Big Data <javase + Linux Elite Training class >_day_04

Source: Internet
Author: User

1: The most common looping statement for the for loop, base syntax                . Used in cases where the number of cycles is known.          for (initialize an expression; loop condition; action expression) {            EXECUTE statement;            .....        }
 /*   for loop writing format: for (initialization expression; loop condition; action expression) {            Execute the statement;    .....        } Initialization expression: Defines the number of times the variable, function, control loop condition: When the condition is true, the loop body is executed, and when the condition is false, the loop increment is ended: The case of the variable increment  */  public  class   fordemo{ public  static  void   main (string[] args) { for  (int  i = 0;i < 11;        ++i) {System.out.println (i); }    }}
 /*   Take advantage of the for loop to calculate the result of 1+4 1 + 2 + 3 + 4 = 10 1+2 and +3 1+2+3 and +4  */ public  class   fordemo_2{ public< /span> static  void   main (string[] args) { //  Define variables, record the result after summing  int  sum = 0;  for  (int  i = 0; I <= 4; ++i) {sum  = sum + I;    } System.out.println (sum); }}
2: Basic syntax--looping statements do ...  while                 Do the. While loop statement is similar to the while Loop statement, the                syntax structure  Do {            EXECUTE statement;            ...        }  while (cyclic conditions);

Big Data <javase + Linux Elite Training class >_day_04

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.