1. Identifiers
The name of the package, class, method, parameter, and variable. A combination of uppercase and lowercase letters, numbers, _, and $ symbols that do not start with a number, cannot make a keyword, and cannot include delimiters and line breaks. (Strictly case-sensitive, maximum length of 255 characters)
2. Literal
Some type of value (specific value)
3. Notes
Cannot execute the text, more for interpretation, there is a single line comment//..., multiline comment/*...*/and document comment/**...*/
4. Separators
A semicolon → is used to denote the end of a statement. such as a=1;b=2;
Spaces → users write each identifier, keywords, etc. separately. such as int a
decimal point → user link object and member relationship. Said... , such as System.out.print ("OK")
Comma → user order describes the variables and arguments that are declared or called. such as int a A, comma can also replace space
curly braces → used to encapsulate a statement as a block of statements, such as Class box{...} Note: Do not add semicolons after curly braces
Parentheses → user-first execution, type conversion, definition, and invocation parameters. such as int d= (A+B) *c
Bracket → user declares an array dimension. such as String [] args;
5. Keywords
A total of 48 words are defined in Java as keywords, have a specific meaning and cannot be used as identifiers;
6. Class Library
Classes and methods provided by the Java environment
7. Variables
A variable is an identifier that represents a literal; a variable in Java must be declared first, then assigned, and then referenced.
Declaration: Type variable name; Multiple variables of the same type can be requested at one time, separated by commas
For example: int x; Declare one variable at a time
int a,b,c; Declare multiple variables at once
Assignment: variable name = expression; You can combine a declaration statement with an assignment statement (type variable name = expression)
For example: int x;
X=1 (Can not write 1=x) → assign x value → equal to int x=1;
Reference: Variable name
variable scope → variable declaration of the program block is valid, after the end of the program block, the variable is recycled, extinct. Variables must be unique within the scope of a variable and cannot be duplicated.
8. Same array
An identifier represents a set of data of the same data type, first declaration, post-creation, re-assignment, and post-reference.
1) One-dimensional arrays
One-dimensional array declaration : Type [] array name, or type array name [];
One-dimensional array creation : array name =new type [array length]; Allows array declarations to be created at the same time: type [] array name =new type [array length], after the creation of the array name [0] to the array name [length 1] so many data.
Assignment : array name [subscript]= expression; The array assignment and reference process should be careful not to subscript overflow.
Each of the arrays is worth referencing : array name [subscript]
Affirming →int x[];
Create →x=new int[3]; Step one or two can be combined as int x[]=new int[3] declaration while creating
Assignment value →x[0]=1;
x[1]=10;
x[2]=15;
Citation →int Y=x[0]+x[1]+x[2];
Special notation, can realize one-time declaration, creation and assignment of all data: type array name []={each data, data and data separated by commas};
Example: Int x[]={1,10,15}
Note: If the array subscript overflow, compile without error, run the Times wrong, if you do not know the length of the array, you can pass System.out.println (x.length); Get the value of the array: array name. length
2) two-dimensional array
Two-dimensional array declaration : Type [[] array name, or type array name [];
A two-dimensional array is essentially a one-dimensional array, but each data in that one-dimensional array is a one-dimensional array, and if each data array has the same length, it is an equal-length two-dimensional array, or an unequal two-dimensional array if the array length of each data is different.
Two-dimensional array creation : array name =new type [length of first dimension] [length of second dimension];
assignment of each data in a two-dimensional array: the array name [a subscript of the first dimension] [a subscript]= expression for the second dimension;
A reference to each data in a two-dimensional array: array name [a subscript for the first dimension] [a subscript for the second dimension]
Basic vocabulary in the Java language