4th Loop Structure Overview and the format of the for statement and its use

Source: Internet
Author: User

04.01_java Language Basics (circular structure overview and for statement formats and their use)
    • A: Classification of cyclic structures
      • For,while,do...while
    • B: Loop structure for statement format:
    • for(初始化表达式;条件表达式;循环后的操作表达式) {    循环体;    }    
    • C Execution Process:
      • A: Execute initialization statement
      • B: Execute a JUDGMENT condition statement to see if its return value is TRUE or False
        • If true, continue execution
        • If False, the loop is ended
      • C: Execute the loop body statement;
      • D: An action expression after the loop is executed
      • E: Go back to B.
    • D: Case Demo
      • Output 10 times "HelloWorld" in the console
04.02_java Language Basics (the practice of looping structures for statements get data)
    • A: Case Demo
      • Requirements: Please output data in the console 1-10
      • Requirements: Please output data in the console 10-1
    • B: Precautions
      • A: Determines whether a conditional statement is a Boolean type, either simple or complex.
      • B: Loop body statement If it is a statement, the curly braces can be omitted, and in the case of multiple statements, the curly braces cannot be omitted. Never omit the suggestion.
      • C: Generally speaking: there is no semicolon on the left curly brace, there is no left brace for the semicolon
04.03_java Language Foundation (the summation idea of the practice of circular structure for statement)
    • A: Case Demo
      • Requirements: Finding the sum of data between 1-10
    • B: Student Practice
      • Requirements: Find the number of even numbers between 1-100 and
      • Requirements: Find out between 1-100 odd and
04.04_java Language Foundation (cyclic structure for statement of practice Narcissus)
    • A: Case Demo

      • Requirements: Output All "daffodils" on the console

      • The so-called Narcissus number refers to a three-digit number whose numbers are cubic and equal to the number itself.

      • Example: 153 is a number of daffodils.
      • 153 = 111 + 555 + 333 = 1 + 125 + 27 = 153
04.05_java Language Foundation (statistical idea of the practice of circular structure for statements)
    • A: Case Demo
      • Requirements: Statistics of "narcissus number" total number of
04.06_java Language Foundation (format and basic use of the loop structure while statement)
    • A: The format of the loop structure while statement:
    • while循环的基本格式:    while(判断条件语句) {    循环体语句;    }    完整格式:    初始化语句;    while(判断条件语句) {    循环体语句;    控制条件语句;    }    
    • B: Execution Process:
      • A: Execute initialization statement
      • B: Execute a JUDGMENT condition statement to see if its return value is TRUE or False
        • If true, continue execution
        • If False, the loop is ended
      • C: Execute the loop body statement;
      • D: Execute control condition statement
      • E: Go back to B.
    • C: Case Demo
      • Requirements: Please output data in the console 1-10
04.07_java Language Foundation (practice of loop structure while statement)
    • A: Summation thought
      • The sum of 1-100
    • B: Statistical Ideas
      • Count the number of daffodils.
04.08_java Language Basics (format and basic use of circular structure do...while statements)
    • A: The format of the circular structure Do...while statement:
    • do {    循环体语句;    }while(判断条件语句);    完整格式;    初始化语句;    do {    循环体语句;    控制条件语句;    }while(判断条件语句);    
    • B: Execution Process:
      • A: Execute initialization statement
      • B: Execute the loop body statement;
      • C: Execute control condition statement
      • D: Execute a Judgment condition statement to see if its return value is TRUE or False
        • If true, continue execution
        • If False, the loop is ended
      • E: Go back to B.
    • C: Case Demo
      • Requirements: Please output data in the console 1-10
04.09_java Language Foundation (the difference between circular structures of three circular statements)
    • A: Case Demo
      • The difference between the three circular statements:
      • The Do...while loop executes at least one loop body.
      • The For,while cycle must first determine whether the condition is true, and then decide whether to execute the Loop body statement.
    • B: Case Demo
      • The difference between a for loop and a while loop:
        • A: If you want to continue using the variable that controls the condition after the loop is over, use the while loop, otherwise use the For loop. I don't know who to use for loop. Because variables disappear early from memory, you can improve the efficiency of memory usage.
04.10_java Language Foundation (cycle of circular structure considerations)
    • A: Must pay attention to control the condition statement control the problem of the variable, do not lose, otherwise it is easy to die cycle.
    • B: Two of the simplest dead loop formats
      • while (true) {...}
      • for (;;) {...}
04.11_java Language Foundation (loop structure loop nesting output 4 rows 5 columns of stars)
    • A: Case Demo

      • Requirements: Please output a 4-row, 5-column star (*) pattern.
      •         *****        *****        *****        *****        注意:        System.out.println("*");和System.out.print("*");的区别        
    • B: Conclusion:
      • Outer loop control number of rows, inner loop control number of columns
04.12_java Language Foundation (cyclic structure loop nested output positive triangles)
    • A: Case Demo
    • 需求:请输出下列的形状    *    **    ***    ****    *****    
04.13_java Language Foundation (Loop structure 99 multiplication table)
    • A: Case Demo
      • Requirements: Output 99 multiplication table on the console.
    • B: Code optimization
    • 注意:    ‘\x‘ x表示任意,\是转义符号,这种做法叫转移字符。    ‘\t‘    tab键的位置    ‘\r‘    回车    ‘\n‘    换行    ‘\"‘    ‘\‘‘    
04.14_java language Base (Control jump statement break statement)
    • A:break Usage Scenarios
      • Only in Switch and loop
04.15_java language Base (Control jump statement continue statement)
    • A:continue Usage Scenarios
      • Only in the loop
04.16_java Language Basics (Control of jump statement labels)
    • Label: Mark a loop to control it
    • Label composition rule: is actually a valid identifier
04.17_java Language Basics (Control adjustment statement exercises)
    • A: Exercises
    • for(int x=1; x<=10; x++) {    if(x%3==0) {    //在此处填写代码    }    System.out.println(“Java基础班”);    }    我想在控制台输出2次:“Java基础班“    我想在控制台输出7次:“Java基础班“    我想在控制台输出13次:“Java基础班“    
04.18_java language Base (Control jump statement return statement)
    • The role of A:return
      • Return
      • In fact, its function is not to end the loop, but to end the method.
    • B: Case Demo
      • What is the difference between return and break and continue?
      • Return is the End method
      • Break is jumping out of the loop
      • Continue is to terminate this cycle and continue the next cycle.
04.19_java Language Basics (Method overview and format description)
    • A: Why should there be a way
      • Improve Code reusability
    • B: What is a method
      • A block of code that completes a specific function.
    • C: Format of the method
    • 修饰符 返回值类型 方法名(参数类型 参数名1,参数类型 参数名2...) {    方法体语句;    return 返回值;    }    
    • D: Format description of the method
      • Modifier: Use public static now. We'll explain the other modifiers in more detail later.
      • Return value type: is the data type of the functional result.
      • Method Name: Conforms to the naming convention. Convenient for our call.
      • Parameters:
        • Actual parameters: is actually involved in the operation.
        • The formal parameter is the method definition that is used to receive the actual parameter.
      • Parameter type: is the data type of the parameter
      • Parameter name: The name of the variable
      • Method Body Statement: Is the code that completes the function.
      • Return: the End method.
      • Return value: Is the result of the function, which is brought to the caller by return.
04.20_java Language Foundation (method summation case and its invocation)
    • A: How to write a method
      • 1, explicit return value type
      • 2, clear parameter list
    • B: Case Demo
      • Requirements: two cases of data
    • C: Method Invocation Plot
04.21_java Language Basics (Method Considerations)
    • A: Method invocation (with a specific return value)
      • A: Call alone, generally no meaning, so not recommended.
      • B: The output is called, but not good enough. Because we may need to do further work on the results.
      • C: Assignment invocation, recommended scenario.
    • B: Case Demo
      • A: Method does not call do not execute
      • B: Methods and methods are lateral relationships, cannot be nested defined
      • C: When the method is defined, the arguments are separated by commas
      • D: Do not pass the data type at the time of method invocation
      • E: If the method has a definite return value, be sure to have return with a value
04.22_java Language Basics (practice of methods)
    • A: Case Demo
      • Requirements: Keyboard input two data, return two number of large values
    • B: Case Demo
      • Requirements: Keyboard input Two data, compare two number is equal
04.23_java Language Basics (method's output star and its invocation)
    • A: Case Demo
      • Requirements: Based on the number of rows and columns entered by the keyboard, the output star in the console
    • B: Method Invocation: (no return value, void)
      • called separately
      • Output Call (Error)
      • Assignment Invocation (Error)
04.24_java Language Basics (practice of methods)
    • A: Case Demo
      • Requirements: Data output According to the keyboard input the corresponding multiplication table
04.25_java Language Basics (Method overloading overview and basic usage)
    • A: Overview of method overloading
      • Summation case
        • 2 integers
        • 3 integers
        • 4 integers
    • B: Method Overloading:

      • In the same class, the method name is the same, and the parameter list is different. Is independent of the return value type.

      • The parameter list is different:

        • A: Different number of parameters
        • B: Different parameter types
        • C: The order of the parameters is different (overloaded, but not in development)
04.26_java Language Basics (method overloading exercises compare data for equality)
    • A: Case Demo
      • Requirement: Compare two data for equality.
      • parameter types are two int type, two double type, and are tested in the Main method

4th Loop Structure Overview and the format of the for statement and its use

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.