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