Java Foundation (Medium)

Source: Internet
Author: User

1. Program Running Process

A. Sequential structure: If there is no process control in the code, the program is supreme and the next line is executed, and the next statement executes after a statement is executed until the end of the program.

B. Branching structure (conditional structure): If;switch.switch chooses only four types: Byte\short\int\char (before Java5), and also supports Enum (JDK5), String (JDK7).

C. Loop structure:

While: Do not need to know in advance how many times the loop executes;

Do While: ibid., only at least once (first done, then judged);

For: Need to know the number of cycles;

D.break,continue and other key words

Break: Terminates the layer loop

Continue: Skipping this layer loop (skipping this loop, performing the Next loop)

2.method (method): A method is a reusable piece of code, a collection of code that completes a separate function in a program.

"Modifier" returns a value type method name (parameter type form parameter, parameter type parameter, ... )

{

Execute the statement;

[return value;]

}

Formal parameters: Used to receive data from outside input when the method is invoked.

Argument: The data that is actually passed to the method when the method is called.

Return value: The method is returned to the data of the environment that called it after execution is complete.

Return value type: The data type of the pre-agreed return value, such as no return value, must be given the return type void.

Method signature: The parameter list of method name and method (can distinguish method);

Method called in the Java language: Object name. Method Name (argument list).

The number, data type, and order of the arguments must match the parameter list of the called method declaration.

The return statement terminates the run of the method and specifies the data to be returned.

Method Features:

It can realize the independent function;

Must be defined inside the class;

It will only be executed if it is called;

It can be reused; After the method ends, the object in the method loses its reference;

3. Initialization of local variables and operating mechanism in memory

Local variables must be initialized before use, where the initialization is actually allocating memory for it;

Local variables are always stored in the stack memory of the method in which they reside, if:

Base type: The value of the variable is stored directly in the variable's memory;

Reference type: The address of the object or array in which the variable is actually referenced;

The variables inside the stack do not need to be garbage collected by the system, and the variables of the stack memory end with the operation of the method or code block.

4. Programming Specification Description

Method names cannot use keywords and reserved words;

The definition specification of a class name: The first letter of the word is capitalized, it is camel-like, and it is made up of a noun or noun phrase with practical meaning: Student, Studentscore,

Method Name specification: First letter lowercase, camel-like, with a meaningful verb or verb phrase: playgame,grow

Naming conventions for packages: All names must be lowercase com. The short name of the company. The short name of the module.

Java Foundation (medium)

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.