1. Variables
1. Definition : A representation of a data storage space, a value that can be changed.
Use of variables:
1: Declare variables
int money; // Open a space of type int in the memory space
2: Assign values to variables
money = 1000;
3: use variables
System.out.println(money);
2. Variable naming rules
1. The variable name consists of letters, underscores, dollar signs, yuan signs, and numbers, which cannot start with a number
2. Can't duplicate the keyword
3. Be meaningful and abide by the naming rules of camel case (the first letter of the word is lowercase, then the first letter is uppercase)
3. Constant
A representation of a data storage space whose value cannot be changed
Use final to modify
Constant names need to be capitalized, and multiple words need to be underlined in the middle
Second, the data type
1.
byte 2 bytes
short 4 bytes
int (default) 8 bytes
long 16 bytes
2. Floating point type Store the number with decimal point
float 8 bytes
double (default) 16 bytes
3.
char
4. Boolean There are only two results, true and false
boolean
5.
String enumerated array ...
Three,
1. Automatic type conversion
Rule 1: If an operand is of double type, the entire expression class is promoted to double type
Rule 2: Meet the conditions for automatic type conversion
Two types must be compatible (numeric types (integer and floating point) are compatible with each other)
The target type is larger than the original type
2.
The results of large data ranges are received with variables of small data, and it is necessary to use strong transfer. Problem: Loss of precision.