Constant
Constants: Fixed amount of constant in program
Categories of constants:
Literal constants: Integer constants, Decimal constants, Boolean constants
Variables defined with the final modifier
Variable
Declaring variables: data type variable name;
Initialize variable: variable name = value;
Initializing a variable will occupy a memory space in memory
Variables can be declared and initialized at the same time: data type variable name = value;
Variables that cannot define the same variable name
Integer type (byte, short, int, long)
Four representations of integer constants:
1. Binary integer: 0B or 0b beginning, int a = 0B12;
2. Eight binary integers: starting with 0, int a = 012;
3. Decimal integer: int a = 12;
4.16 binary integers: Starting with 0 x or 0x, int a = 0x12;
The numbers can be underlined
Integer constants for the Java language are type int by default, declaring a long variable to be followed by L or L
Decimal type (float, double)
A decimal type is also known as a floating-point type, where float represents a single-precision type, and double represents a doubles type, but neither can represent exact decimals to represent exact decimals, with the Bigecimal type
The decimal constant is the double type by default, and if you want to represent the float type, add F or F after
Scientific notation: 3.14e2-phase equals 3.14 * 10^2
Character type (char): characters, letters, and symbols
One character in Java takes two bytes
ASCII code that can correspond to characters in decimal digits
ASCII code that can correspond to characters in hexadecimal digits char a = "\u0041"; # four-bit
Java Data types