Java Language Basics 001

Source: Internet
Author: User
Tags java keywords

1, the basic structure of Java program can be divided into package, class, Main () main methods, identifiers, keywords, statements and comments and so on .

2, Identifiers and keywords are case sensitive .

3, the Main method is the entry point of the application, the Java program starts from the method, main is the name of the main method, the programmer can not change.

4. identifier is a name that identifies a valid sequence of characters for the class name, variable name, method name, array name, and file name.

5. Naming rules for identifiers:

(1) The Java language identifier consists of letters, numbers, underscores, and dollar symbols, and the first character cannot be a number.

Illegal: 7word, 5fox

(2) The Java language uses the Unicode standard character set and can recognize up to 65535 characters.

(3) Identifiers cannot be Java keywords and reserved words. Illegal: This,goto;

(4) Identifiers are case-sensitive in Java speech.

6. There are 8 basic data types in Java, 6 of which are numeric types, and two are character types and Boolean types.

7. A long variable must be assigned a value of L or L at the end.

8, floating type assignment when the end must be added F or f,double type assignment when the end can be added D or D, also can not add.

9. Naming rules for variables:

(1) The variable name must be a valid identifier.

(2) Variable names cannot be duplicated.

(3) You should choose words that are meaningful and easy to understand as variable names.

10, the amount of the process that has not changed during the program is called a constant (constant), also known as the final variable. Constants can only be assigned once in the entire program.

11. Constant names are usually capitalized but not required.

12, the effective scope of the variable refers to the program code can access the range of the variable, according to the area of the variable can be accessed to divide the variables into member variables and local variables .

13, member variables are valid throughout the class, and can be divided into static variables and instance variables . Static variables are statically variable before member variables, and the valid range of static variables can be Kua-class.

When a local variable has the same name as a member variable, the member variable is temporarily invalidated, and if you want to invoke a member variable, you need to use the class name. Static variable invocation.

Java Language Basics 001

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.