1 , Keywords: It is a word that gives special meaning to a language.
reserved words: In fact, there is no special meaning, but prepare the words to be used later.
2 , identifiers: is actually a custom noun in the program. such as the class name, variable name, function name. Contains 0-9, A-Z, $, _;
Note:
1 ), the number may not begin.
2 ), you cannot use keywords.
3 , constants: is the data that does not change in the program.
4 , variables: is actually a storage space in memory that is used to store constant data.
function: convenient for operation. Because some data is uncertain. So determine the noun and storage space for the data.
Features: Variable space can be reused.
When do I define a variable? as long as the data is uncertain, the variable is defined.
What are the necessary elements for the opening of variable spaces?
1 , what data does this space store? The data type.
2 What's the name of this space? The variable name.
3 , what is the first data for this space? The initialization value of the variable.
Scope and lifetime of variables:
Scope of the variable:
The scope starts at the position defined by the variable and ends with the curly brace where the variable is located;
Life cycle:
The variable is alive in memory starting at the defined position;
When a variable reaches its scope, it disappears in memory;
Data type:
1 ): Basic data Type : Byte, short, int, long, float, double, char, Boolean
2 ): Reference data type : arrays, classes, interfaces.
levels from low to High are: Byte,char,short ( These three-lateral)-->int-->float-->long-->double
Automatic type conversion: from low to high level, the system automatically turn;
To force type conversions: Under what circumstances? Assign a high-level number to a variable that has low levels of that number;
This piece of advice to everyone to see some Java video, the video is more clear.
Operation Symbols:
1 ), arithmetic operators.
+ - * / % %: any integer modulus 2 is not 0 is 1, so as long as the change by the modulus can be achieved switching operations.
+: connector.
++,--
2 ), assignment operator.
= += -= *= /= %=
3 ), comparison operator.
Features: This operator is characterized by the result of the operation, either True or false.
4 ), logical operators.
& | ^ ! && | |
logical operator except! are used to concatenate two Boolean expressions.
&: only both sides are true and the result is true. Otherwise, it is false.
|: as long as both sides are false the result is false, otherwise it is true
^: XOR: And or a little different.
on both sides, the result is false.
It is true that the results are different on both sides.
& and && differences: & : Regardless of the result on the left, the right side participates in the operation.
&&: Short Circuit and if the left is false, then the right side is not a parameter and operation.
| and | | difference: | : operation on both sides.
|| : Short Circuit or if the left is true, then the right side does not participate in the operation.
5 ), bitwise operators: Operators for manipulating bits.
& | ^
<< >> >>> ( unsigned Right shift)
exercise: Swap data for two variables. No third-party variables are required.
int a = 3,b = 5;-->b = 3,a = 5;
A = a + B; A = 8;
b = a A; b = 3;
A = a-B; A = 5;
A = a ^ b;//
b = a ^ b;//b= a ^ b ^ b = a
A = a ^ b;//a= a ^ b ^ a = b;
Exercise: Efficiently figure out 2*8= 2<<3;
Java learning needs to be constantly summed up and practiced, so that you can stand on the higher level.
Java Syntax Basics