Beginners To learn Java, is javase, every day I learn from the day and notes, I hope you can criticize and advice, and promote common progress! The third day!

Source: Internet
Author: User

    1. In a looping statement, the while loop is the first to judge the condition, and the loop body is executed only if the condition is satisfied. The Do-while is to execute the loop body first, then judge the condition, the condition satisfies, then continues to execute the loop body. In other words, the loop body is executed at least once in the Do and loop statement, regardless of whether the condition is satisfied.
    2. In the IF statement, if the judgment is not followed by {}, then, if the judgment statement is true, execute if a statement, if False, the next statement does not execute. With {}, the loop body is the contents of {}.
    3. In the conditional expression of all the loop statements, or in other conditional expressions, the last value must be a Boolean type, otherwise the program will give an error.
    4. The simplest form of expression of two infinite loops

(1). for (;;;) {} (2) while (true) {}

    1. For loop (loop) Nesting Exercise 1: Printing out

The source code is as follows:

Expansion Exercise 1: Try to hit the top line for five *. The bottom of the behavior is a *.

Expansion Exercise 2: Try to print out the * to replace the number. That is, the first Act 1, the second Act 1 2, the third Act 1 2 3 .....

For loop nesting Exercise 2: Printing out

Expansion Exercise 1: Print out

    1. For break and continue two statements, the two can only be used for looping structures. Break is used to jump out of the current loop, and continue is used to end the loop and continue the next loop. When these two statements exist alone, there can be no language underneath, because Java access is not available and the compilation does not pass. (Can be used in an infinite loop, we can set multiple judging conditions in an infinite loop, and then we can see whether the loop continues or exits)

    1. Function: is a separate applet that defines a specific function in a class. In layman's terms, we call it a method.

Format of function: Modifier returns a value type function name (parameter type parameters 1 parameter type Parameters 2 ...)

{

Execute the statement;

return value;

}

Formal parameter: is a variable that stores the actual arguments passed to the function when the function is called.

Actual parameter: The specific value passed to the formal parameter.

Note: In a function, you can only call a function and no longer define a function.

    1. When a function operation has no specific return value, the return value type can be represented by the Void keyword, then the return statement in the function can be omitted from the last line if not written. When a function is modified by void, it cannot be output, that is, not enough system.out.println ();
    2. How to define a function:
      1. Since the function is a separate function, let us first clarify what the result of its function (the return value type) is.
      2. Determines whether undefined content (parameter list) takes part in the process of defining a function.

Exercise 1: Define a function that prints a rectangle that can print out the number of rows in a specified sequence.

Exercise 2: Define a function that can print out a 99 multiplication table.

    1. Overloading of Functions (overload): In the same class, more than one function with the same name is allowed, as long as they have a different parameter type or a different number of arguments.

When to use overloads, when the functions defined are the same, but the unknown content that participates in the run is different. Then, a function name is defined to indicate its function, which is easy to read, and is distinguished by the difference in the parameter list.

    1. Array: is a collection of data of the same type, as the popular point says, an array is a container. The advantage of arrays is that the elements in an automatic array can be numbered from 0 to facilitate manipulation of these elements. Declaration method int[] x = new int [3]; (Note: x is stored in stack memory, int[] is stored in heap memory, X represents the first address of this array and is used to point to int[3 in heap memory])
    2. Java program at run time, need to allocate space in memory, in order to improve the efficiency of computing, there are different areas of space division, because each area has a specific way of processing data and memory management.
      1. Stack memory: Used to store local variables, and when the data is used, the occupied space is automatically freed.
      2. Heap Memory: #数组和对象, the instances created by new are stored in heap memory.

#每一个实体都有内存地址值

#实体中的变量都有默认初始化值

#实体不再被使用, it is reclaimed by the garbage collection station for an indeterminate period of time.

Beginners To learn Java, is javase, every day I learn from the day and notes, I hope you can criticize and advice, and promote common progress! The third day!

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.