And then brother combed the Java Knowledge Point--Process Control (VI)

Source: Internet
Author: User

Branch structure (if...else, switch)

 1. If Else statement format

if  (conditional expression) {Execute code block;  }  Elseif(conditional expression) {Execute code block;  }  Else{execute code block; }

2. Switch statement

Switch(variable) { Caseconstant Value 1: statement 1;  Break;  Caseconstant Value 2: statement 2;  Break;  Caseconstant Value 3: Caseconstant Value 4: Caseconstant Value 5: statement 5;  Break; default: statement;  Break; }

"Knowledge points":

A) switch: When the values of multiple variables go through the same process, you need to follow the notation of constants 3, 4, and 5 to merge cases.

b) If else and switch differences?

If else is suitable for interval comparisons, for example: greater than 60 less than 80 for qualifying, etc.

switch is suitable for specific equivalents. For example: water temperature of 100, indicating that the waters opened,

loop structure (while, Do...while, for )

  "Knowledge points"

     For format:

1. Initialization conditions

2. Cyclic conditions

3. Iteration Conditions

4. Circulation body

for (1;2;3) {

4

}

Execution order: 1-2-4-3-2-......-4-3-2

Until the loop condition is not satisfied, exit the current loop

  Interview Title: Output 99 multiplication table

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

  While format:

while (2) {

4

3

}

  

  Do...while format:

1

bo=

4

3

}while (2)

  Break and continue tags are used:

And then brother combed the Java Knowledge Point--Process Control (VI)

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.