The main knowledge point of the Java language

Source: Internet
Author: User

1. What is an identifier

The sequence of characters used by Java to name features such as packages, classes, methods, parameters, variables, and so on, is called an identifier.

2. Naming rules and habits of identifiers

Consists of a letter, number, underscore (-) dollar sign ($)

Cannot start with a number

Case sensitive

Cannot be a reserved word and keyword in Java (keywords: there are some specific meanings in Java, and strings that have special purpose are called keywords. All are lowercase. Reserved words: No purpose defined, but reserved for use

Camel-named: schoolname

See the idea (use meaningful English words)

Class name capitalize, variable name and method first letter lowercase

No more than 15 characters in length

3. What is a variable

A variable is actually a small area of memory, using the variable name to access the area. Therefore, each variable must be declared before it is used, and then it must be assigned before it can be used.

Variable: Data with variable value in program execution

such as: int i=100;

int y;

y=i+10;

Variable name: Defines the identifier of the variable

Variable value: The data that is loaded in the memory unit

4. Declaration and initialization of variables

Java variables must be declared and initialized before they can be used

such as: public class schoolname{

public static void Main (String [] args) {

int a = 200;

int b=a+10;

System.out.println (b);

}

}

5. Classification of variables

By the data type that belongs to:

Basic type variable: holds the original value. (Real raw data)

Reference type variable: holds the reference value. (a reference to an object, not the object itself)

Divided by the declared location:

Local variables: Variables defined inside a method or statement block

Member variables: Variables that are internally defined by methods outside of the class

Special note: There can be no declaration of variables outside the class body

The main knowledge point of the Java language

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.