The path of Java Learning (ii) Flow control statements

Source: Internet
Author: User

If, if...else ... Statement

        if (true) {            System.out.println ("execute when True");         Else {            System.out.println ("execute when false");        }

Switch statement

 switch   (a) { case  1:  switch  System.out.prin            TLN ("perform"  break  ;  case  2: System.out.println ( "Duty            The ");         break  ;  default  : System.out.println ( "when            ");         break  ; }

Break and continue can achieve sequential interrupts, but there are different jumps

Break: Force the program to interrupt the loop to leave the loop body;

Continue: Forcing the program to jump to the beginning of the loop, the statement after the continue statement will no longer execute, jump out of this cycle;

While statement

         while (a<100) {            // determine if the statement in white brackets is true, and execute the method in {} When it is true             System.out.println (a);            A+ +;        }

Do...while ... Statement

         Do {            // the statement in do inside is executed first to determine if the while statement is true             System.out.println (a);            A+ +;            System.out.println (a);          while (a<100);

For loop

 for (int i = 0; i < args.length; i++) {            }

99 Multiplication Table

 for (int i = 1; I <= 9; i++) {            for (int j = 1; J <=i; J + + ) {                System.out. Print (J+ "*" +i+ "=" + (i*j) + "\ T");            }            System.out.println ("\ n");        }

The path of Java Learning (ii) Flow control statements

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.