Basic data types
Basic data types
1 byte (byte) = 8 bit (bit)
- Integral type. BYTE (8-bit) short (16-bit) int (32-bit) long (64-bit)
- Floating point type. Float (single precision. 32-bit) double (doubles). 64-bit)
Add F to the value followed by the float type, without representing the double type
Example: 3.14 for double,3.14f on behalf of float
- Character type. char (16-bit)
Char in Ps:java is 16 bits, which is 2 bytes, and char in C is 8 bits, which is 1 bytes
- Boolean type. Boolean (1-bit)
Type conversions
Turn left to right, convert directly
Turn right to left, cast
Operator
Divided
Unary operator, two-ary operator, ternary operator
- Unary operators: + + (self-increment)-(self-subtraction)-(minus) + (plus sign)! (non) ~ (bitwise negation) ...
- Binary operators: +-*/% + = = *=/=%= && (with) & (bitwise VS) | | (OR) | (bitwise OR) &&= | | = = (Assignment) = = (judging if equal)! = > >= < <=
- Ternary operator:?:
Priority level
Attention:
Three shift operators
>>: Value Right Shift
<<: Value left Shift
>>>: Unsigned Right shift, ignore sign bit, empty 0
Basic data types and operators for Java