首页 > 编程语言 > 详细

English Version of Java Study - Lesson 1

时间:2019-08-04 10:08:15      阅读:55      评论:0      收藏:0      [点我收藏+]

I. Process Control - Selection Structure

 A. Process Control Structure

  1. Introduction to the process signs

   技术分享图片 Process begins / ends      技术分享图片 Judge and branch

 

   技术分享图片 Calculation procedure.    技术分享图片 Connection

 

   技术分享图片 Input / output instructions   技术分享图片     Process line

  2. Introduction of Process Control Structure

 技术分享图片技术分享图片技术分享图片

 

    Sequence          Selection              Loop

    a. Sequential structure: Sequential structure refers to the structure in which the program      executes each statement in turn from top to bottom without any judgment or jumping.      The preceding examples all adopt sequential structure.

    b. Choose structure: Choose structure to execute different code according to the result of      condition judgment. The selected structure can be subdivided into single-branch      structure, double-branch structure and multi-branch structure. Java provides if control      statements and switch statements to implement the selection structure.

    c. Loop structure: Loop structure is to execute a piece of code repeatedly according to      the judgment condition. Java provides while statement, DO-WHILE statement, for      statement to implement loop structure.

 B. Selection Structure

  1. "If"

   a. There are three different kinds of "If" control statement. 

    - Single branch structure 

    - Double branch structure

    - Muti-molecular structure

   b. Using "If" for single branch structure

    - Format: 

      技术分享图片

   c. Steps of Judge the result of the expression:

    - Judge the expressed results.

    - Execute the statement if the result of the expression is true.

    - If the result of the expression is false, skip the statement.

  2. "If-else"

   a. Format:

     技术分享图片

   b. Steps of Judge the result of the expression:

    - Judge the result of the expression

    - If the result of the expression is true, execute statement 1

    - If the result of the expression is false, execute statement 2

  3. Using multi-branch if statement to realize multi-branch processing

   a. The grammatical format of the multi-branch if statement:

      技术分享图片

   b. The execution steps of the multi-branch if statement:

    - The result of expression 1 is judged.

    - If the result of expression 1 is true, statement 1 is executed; otherwise expression 2 is judged.

    - If the result of expression 2 is true, statement 2 is executed; otherwise statement 3 is executed.

 C. "Switch"

  1. Format: 

   技术分享图片

  2. The execution steps of the switch statement:

   - Calculate the value of the expression after switch

   - Comparing the calculated results from top to bottom with the constant values after case

   - If equal, the code block after the constant is executed and the break statement ends.

   - If the constants after any case do not match, execute the statement in default

NOTE:

01. If you need to jump out after each case is executed, don‘t forget to write a break after each case.

02. Constants after case cannot be the same

03. The order of default blocks can be changed, but attention should be paid to their execution order. Normally, default blocks are placed at the end, or they can be omitted.

English Version of Java Study - Lesson 1

原文:https://www.cnblogs.com/study-java-with-english-syq/p/English-Version-of-Java-Study-Lesson-1.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!